Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.††Topics such as question regarding the System.Data namespace are appropriate.††Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old December 24th, 2004, 09:20 PM
Registered User
Join Date: Dec 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how can i link to sql-server with ado.net[B)]

what's wrong with these sentences below?

 Dim cnn As New SqlConnection("server=zjx2000\testsqlsvr;User=zjx; pwd=680228;database=WroxJokeShop")
Dim cmd As New SqlCommand("getdepartments", cnn)
cmd.CommandType = CommandType.StoredProcedure

when it step to "cnn.open()",I got an error "server not exist or refuse to access",something like that,but in a Access adp,the same connection string is ok! My english is poor,I hope you understand what I say.Thanks for your reply!

Reply With Quote
  #2 (permalink)  
Old December 25th, 2004, 08:50 AM
Authorized User
Join Date: May 2004
Location: Karachi, Sindh, Pakistan.
Posts: 83
Thanks: 0
Thanked 1 Time in 1 Post

Dear zjxgjp!

There may be several causes of not working for the code of yours:-

Cause 1
When installing SQL Server, you can install either a 'defalt instance' (the default) or a 'named instance'. With a default instance you need to write only the name of the server in conn str like this:
With a named instance, however, you would write the same thing as:

Now, the conn str you have used uses this second approach. Make sure that you have a named instance and that the instance name is correct. if you don't have a named instance, use only the name of the server as in the example above.

Cause 2
For your conn str to work properly, your SQL Server must be configured to use Mixed Mode security (rather than Windows Security) as you are providing a user name and password. If your server is configured to use Mixed Mode security then make sure your user name and password are correct and that the user has permission to acces the database. If any of these conditions is not met, the conn will fail.
If your server uses Windows authentication then modify your conn str to resemble the one below:
  "Server=server_name;Database=databse_name;Integrat ed Security=SSPI"

For specific help as to how to grant a user access to a databse or change the SQL Server security mode, plz check SQL Server Books online. I hope it should help you resolve the problem.

Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to link Access to SQL Server echovue Access VBA 0 May 31st, 2006 04:28 PM
ADO.NET connectivity problem with SQL Server !!! virajp ADO.NET 2 December 5th, 2005 10:51 PM
SQL Server with ADO.NET dounme SQL Server 2000 4 February 8th, 2005 08:19 PM
ADO.Net slower than SQL Server Query Analyzer s5g5r ADO.NET 1 January 26th, 2005 08:49 PM
Ado.net performance question (SQL server vs OleDB spamp ADO.NET 1 August 2nd, 2004 10:37 AM

All times are GMT -4. The time now is 03:08 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.