Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
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
 
Old October 12th, 2006, 08:54 PM
Authorized User
 
Join Date: Oct 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to salemkoten
Default Connect to SQLserver20005 express

Hi all,
I have some errors in connecting to SQLserver20005 express.
In a project, I connect directly (by sqlconnection) and indirectly (by code), if I run this connect successfully then the other can't connect.
I use ADO.NET and connectionstring the same.
The error appears at:
Code:
If SqlConnection1.State <> ConnectionState.Open Then SqlConnection1.Open()
Error:
Cannot open database "BeBi" requested by the login. The login failed.
Login failed for user 'BUCA\hoalt'.

Thanks in advance.
SLKT

 
Old October 12th, 2006, 11:43 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

It is not clear what you are asking. Are you saying that you have Multiple Data Sources? I am using SQL Server 2005 Express and I had to pay close attention of the placement of the web.config file.
 
Old October 13th, 2006, 01:57 AM
Authorized User
 
Join Date: Oct 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to salemkoten
Default

Peace95, I have only a database, and only a table, in only the project I have 2 forms.
In a form(call A), I connect to this table by sqldataadapter.
In other one(call B), I connect by code not sqldataadapter.
If I run A before, A connects successfully; then B runs, B fails
And if B runs before, it is successfully, the other fails.
I can connect by this 2 types to the same database in the same project?

 
Old October 13th, 2006, 12:04 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default

Make sure to CLOSE the open connection before opening the connection for the next form. For example, u have form A open, the close form A, before attempting to open connection to Form B, even though it is the same table. Not sure, what you mean by opening form B by code. You are using either the Data Reader or Dataset(DataAdapter).

Hope this helps.
 
Old October 13th, 2006, 11:26 PM
Authorized User
 
Join Date: Oct 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to salemkoten
Default

Peace95,
I've found the reason.
In B-form, connectionstring="Data soucre=HoaLT\SQLEXPRESS;AttachDBFilename=BeBi...."
I must use Initial Catalog instead of AttachDBFilename
It attach one more file into my database, this is the reason of errors.
Thank you anyway.
SLKT






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to connect to ORACLE 10g Express Edition using matrixbegins Struts 1 June 22nd, 2009 05:38 AM
connect to SQL EXPRESS 2005 angelboy C# 2005 0 June 8th, 2007 01:34 PM
Connect to MSSQL 2005 express salemkoten SQL Server 2005 2 October 11th, 2006 04:46 AM
Connect to Outlook Express email Wall st Guru Excel VBA 1 February 23rd, 2006 09:18 AM
How to connect SQL Express in VB .NET/win Appli. venkikrao General .NET 0 January 4th, 2006 12:37 AM





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