Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql Server does not exist..

Author  Topic 

roxcy
Yak Posting Veteran

58 Posts

Posted - 2007-08-31 : 23:49:39
Hi,
i am repeatedly getting this error while trying to open connection.Sql Server does not exist or Access Denied.I am trying to connect to my local server.


Dim inscmd As New SqlCommand
myconn = New SqlConnection("server=local;database=TEST;Trusted_Connection=yes;user id=;password=;")
inscmd = New SqlCommand("Insert into Details(ID,Name,Address) Values (@ID,@Name,@Address)", myconn)
inscmd.Parameters.Add("@ID", SqlDbType.NChar, 10)
inscmd.Parameters.Add("@Name", SqlDbType.VarChar, 40)
inscmd.Parameters.Add("@Address", SqlDbType.VarChar, 40)

inscmd.Parameters("@ID").Value = txtId.Text
inscmd.Parameters("@Name").Value = txtId.Text
inscmd.Parameters("@Address").Value = txtId.Text

Try
inscmd.Connection.Open()
inscmd.ExecuteNonQuery()
inscmd.Connection.Close()


Plz correct me..

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-09-01 : 01:23:47
Not sure that this will help, but you've got an incorrect connection string. You either provide Trusted_Connection=yes or user id and password. You don't specify both. A trusted connection means to use the security context of the person logged into Windows. Userid and password means to use SQL authentication.

If that doesn't work, try specifying your actual hostname instead of local. If you installed a named instance, then you'll need hostname\instancename.

Also verify that the SQL Server service is started.

Are you able to connect to the SQL Server via the client tools? For 2000, that would be Enterprise Manager and Query Analyzer. For 2005, you use Management Studio.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -