.Net connect process to SQL 2000 sp4

Hello - hopefully an easy one for someone who knows what they are doing...  i have read a number of tutorials, but am completely new to .net.

 I am trying to start simple, I would just like to write a code which reads a record from a table, saves the value as a variable, then simply displays the variable on the screen.

My server is the local server, has a trusted connection, the SQL database is called UserDB.  The table is called Users.  The column I'd like to read is UserID (contains numeric values, 6 digits)

I have included the code below, and the error I receive at the bottom:  Any advice is greatly appreciated!

 <%@ Import Namespace="System.Data.SQLClient" %>
<%

Dim UserIDoutput
Dim strConn as string = "server=localhost;Trusted_Connection=yes;database=UserDB"
Dim MyConn as New SQLConnection(strConn)
Dim MySQL as string = "Select (UserID) from (Users)"
Dim objDR as SQLDataReader
Dim Cmd as New SQLCommand(MySQL, MyConn)

Myconn.Open()
objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
While objDR.Read()
 UserIDoutput=objDR("UserId")
 response.write (UserIDoutput)
End While
%>

 The error is

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near ')'.
Line 16:
Line 17: Myconn.Open()
Line 18: objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
Line 19: While objDR.Read()

0
CKlemm
12/4/2007 8:52:47 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

2 Replies
602 Views

Similar Articles

[PageSpeed] 29

Your SQL is invalid. Try this: Select UserID from Users

0
Chris
12/4/2007 9:56:06 PM

WOW, I knew that would be a quick answer for someone! 

 The tutorial I had read didn't put () around anything but table-name and database-name, so I thought it was required.

Took out the () and it worked as expected!  Thanks again!

0
CKlemm
12/4/2007 10:05:21 PM
Reply:

Similar Artilces:

SQL Server Reporting Services for SQL SERVER 2000 AND Visual Studio.NET 2005 .NET 2.0
Hi, Which version of SQl Server Reporting Services will work with SQL SERVER 2000 in pararrel with ASP.NET 2.0 (.NET 2.0 framework)?  Thanks, Azam HighOnCodingWanna get high! Hi, Okay I got the answer. Yes, we can use the SQL SERVER 2005 Reporting Services with SQL SERVER 2000. HighOnCodingWanna get high! ...

Unable to connect to Sql 2000 from .NET
Hi All,    I am trying to connect to an SQL SERVER in a remote production server from ASP.net using following code.   Dim conProd As New OleDbConnection("Provider=SQLOLEDB.1;Data Source=ServerName;UID=User Name;PWD=Password;Initial Catalog=Database")conProd.Open()I am getting following error while running this script [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.  But I am able to connect to this server using following three other ways:1) Using query analyzer2) I created DSN and performed test connection, it succed...

Connection to SQL 2000 database with .Net 1 Application
Hi there,   Has anyone ever encountered problems making .Net applications connect to a SQL database on SQL 2000 with SP3a?   It's running on a virtual machine with a Windows Server 2000 Std with SP4, the .Net application is working with .Net Framework 1.1.4322.573. For some reason it can't connect to the SQL database using the specified username and password in the web.config file even though the user exists in the SQL database. I've tried using the SA password but this still doesn't work. I can logon to SQL Query Analyzer using the SA password but not usin...

vc#.net can't connect to SQL 2000
Hi, When I try to connect to SQL 2000 it test successfully, but prompts this error after clicking ok: Unable to connect to database. It is only possible to connect to SQL Server Desktop Engine databases and Microsoft Access databases with this version of Visual Studio. I have SQL 7 installed also, and it works fine. I'm running XP with Visual C#.net Thanks I had this problem a while back with VB.NET, unfortunately you'll need to shell out more cash or get your company to purchase either Visual Studio.NET professional or architect in order to connect to a SQL db throu...

Where to get SQL server 2000 reporting service for VS.NET?
Where to get SQL server 2000 reporting service for VS.NET? Start here: http://www.microsoft.com/sql/reporting/default.aspIf my post is your answer, please mark it as the answer. It will bring good karma.Crystal AllianceMy BlogFlorist Blogs...

How to connect SQL Server 2000 in visual studio.net 2005
How can i connect my ASP.NET web application with my sql server 2000. i used visual studio 2003, and there we drag and drop the data adapter and  then a sql connection and then use them in our application. but here we have only sqldatasource or something. so please tell me to make the connection and data retrieval procedure. Kumud Tripathi You can drag a SQL Data Source object onto you web form and select configure data source. This will give you a wizard to connect to a database, and also allows you to set up insert, delete, update statements. You can then use this datasource to...

Urgent, Dot Net 2005 cannot connect to SQL server 2000
I am using VS .net 2005 to  develop a web application with sql server 2000, but the SQL servrer 2000 is setup on other computer,so, my web server is setup on A machine and SQL servr is setup on B machine.I got a problem when i try to connect to SQL server through the Web form as following error."An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a c...

Net:Net:Net::LDAP::FAQ
------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

Frustrating Error connecting to SQL 2000 from IIS with .NET 2.0
I am getting the following error when connecting to SQL 2000 from IIS with .NET 2.0. It works perfectly with the Test Server that comes with VS 2005.   An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack t...

ado.net 2.0 and sql server 2000 connection error
I am trying to make a simple connection to my sql server, but am getting an error.  I am not sure why it says SQL Server 2005 in the error as we use 2000.  I have found others to have the problem on the web, but have found no answers.  One person said the sql connection worked when he downgraded to 1.1; however, I'd like to avoid that.  Here is my code:   <%@Import Namespace="System.Data.SqlClient" %> <script runat="server"> Sub Page_Load() Dim conNorthwind As SqlConnection   conNorthwind = New SqlConnection("Server=1CDRSRV4; uid=username; pwd...

Help: SQL 2000 connection error(.NET 2.0, VS 2005)
Moderated by XIII, please use a normal font size for better readability: for some reason, my web application can not connect to my SQL 2000 my application is based on .net 2.0 (IIS 5.1) using vs 2005 workstation does not install any sql server sql 2000 locates at the remote server. the sql server can be connected via vs environment (data connnection), therefore, i think the connection string, server name and instance name is correct i have tried all the solution i can find online, but it is not working LocalSQLServer connection string has been removed in GobalSetting ...

Free .Net and Sql Server Training Videos for Developers just getting started
I figured since this is the Getting started forum I would mention a great .Net training video site with some free videos.http://www.TechnicalVideos.netThanksMike James...

How to connect Microsoft Visual Basic .NET to MS SQL Web Server 2000?
Need to connect VB .NET to MS SQL Web Server database. The message is "Can not  connect databases remotely" Thank you!ASP.NET Hosting...

pb 10.0-sql server 2000-ado.net connect problem
Hi, I am using Powerbuilder 10.0 , XP SP2 , Microsoft SQL Server 2000 and the Net Framework is installed. I am having problem connecting to Microsoft SQLSERVER 2000 using ADO.NET My connection is // Profile sqlado SQLCA.DBMS = "TRACE ADO.Net" SQLCA.LogPass = "123" SQLCA.LogId = "sa" SQLCA.AutoCommit = True SQLCA.DBParm="Namespace='System.Data.OleDb',DATASOURCE='internetpc' ,Database='db1',Provider='SQLOLEDB',PROVIDERSTRING='database=db1' ,DelimitIdentifier='Yes',PBCatalogOwner='dbo',Default...

Web resources about - .Net connect process to SQL 2000 sp4 - asp.net.getting-started

First Capital Connect - Wikipedia, the free encyclopedia
( FCC ) is a British train operating company , owned by FirstGroup , operating the Thameslink Great Northern franchise . FCC operates passenger ...

Connect
mobile photography technology, culture and community www.dpreview.com News Reviews Features Phones Tablets Cameras Apps Forums Mobile photography ...

CloudCraze Connects Consumers To Facebook Brands Via Cloud Technology
Brands on Facebook are always looking for new, efficient ways to connect with customers . CloudCraze, which recently released its 3.0 e-commerce ...

Law Firm Partners Need To Connect Personally With Each Other To Manage Their Firm Well Together
... private lawyers must remember that their firms are businesses (if not typical businesses), in order to run their firms well, they need to connect ...

IFTTT gains support for Honeywell Total Connect Comfort with new channel
... creative ideas to make this even better and one of those is home automation. With that in mind, IFTTT is unveiling its Honeywell Total Connect ...

Hillary Clinton connects with Latina voters - Business Insider Deutschland
Clinton is building a targeted campaign infrastructure aimed at Latinas.

Crave giveaway: 128GB SanDisk Connect Wireless Stick
Win a $99.99 compact storage device for the mobile era that has its own Wi-Fi network built right in. Can't beat that for a Black Friday deal. ...

Google Search Connects Trump To Hitler
Searching for Trump's book suggests Mein Kampf as related search

Salesforce Connect Improves Data Integration for Enterprise Apps
Salesforce has renamed and updated its Lightning Connect services to help users access and manage data in external enterprise apps.

Trends For 2016, Part 2: Consumers Find Tech Transformed, Connect With Their Tribes, Reel From Shock
My research, business experience, discussions with clued-in clients, and a mountain of data point to the following trends as the ones to watch ...

Resources last updated: 12/21/2015 2:07:25 AM