Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 24th, 2004, 10: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!

  #2 (permalink)  
Old December 25th, 2004, 09: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.


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 11:51 PM
SQL Server with ADO.NET dounme SQL Server 2000 4 February 8th, 2005 09:19 PM
ADO.Net slower than SQL Server Query Analyzer s5g5r ADO.NET 1 January 26th, 2005 09:49 PM
Ado.net performance question (SQL server vs OleDB spamp ADO.NET 1 August 2nd, 2004 10:37 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.