Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Tuesday, March 27, 2012

Connecting to SQL Server 2005 Express

I am having major issues connecting to SQL Server 2005 Express from Visual Basic 2005 Express, which I have tried on multiple PCs but to no avail. Can somebody please explain to me what I'm doing wrong?

1) I install SQL Server 2005 Express and Visual Basic 2005 Express (With .NET framework and SQL native client of course)
2) I open SQL Server using Management Studio and going in with windows authentication. It automatically sets the log on name to computername\SQLEXPRESS.
3) I create a new database called Test and add one table to it
4) I go into Visual Basic 2005 and create a new project.
5) I go to the projects application settings (Properties - Settings).
6) I set up a new connection string, choosing SQL server as the conection type and then on the Connection Properties window it asks me to select the mdf file for the database. I choose the file Test.mdf from the directory C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\
7) I click on Test Connection.

When I do this on two out of the three home PCs I get the error:
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test.mdf".Operating system error 32: "32 (error not found)".
An attempt to attach an auto-named database for file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

The third PC gives me a different error:

Cannot open user default database. Login failed. Login failed for user 'DAVE\David'.

I get the same errors when I try to use a connection string inside the code directly. Does anyone have a clue as to why these errors are occuring? Do I need to set up security or something else on the database first, or is there another reason? If anyone can please help me get to the bottom of this or provide a web address where I can get the answer (step by step instructions on how to connect) then I would be most grateful.

error code 32 means:
"The process cannot access the file because it is being used by another process."

So, either use a different file name for your connection in Visual Basic 2005, or try disconnect your connection in SQL Server using Management Studio.

|||

pse post the Connection string... it seems like u r trying to attach a db called Test....

in the second error .. check what is the Default Database given for user DAVE\David.... the default database should exists and this user should be a user of that db.... for debuggin purpose ... just change the default database of this user to Master and try... it will connect...

Madhu

|||

Hi, I get the same error as the original poster of this thread. I have no other database with similar name or anything, and i have not, as far as i know, any other connections to this database, since I just created it. Do you have any idea of how I should go about this?

Thanks

Niclas

sqlsql

Sunday, March 25, 2012

Connecting to SQL 2005 using VB6

Is there some reference material that shows how to connect to a SQL 2005 DB
using Visual Basic 6? Any help is appreciated.Charlie (jadkins4@.yahoo.com) writes:

Quote:

Originally Posted by

Is there some reference material that shows how to connect to a SQL 2005
DB using Visual Basic 6? Any help is appreciated.


You find the reference for ADO on
http://msdn2.microsoft.com/en-us/library/ms675532.aspx. ADO is a piece
of crap in my opinion, but*it's nevertheless the best option for VB6.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Monday, March 19, 2012

Connecting to Microsoft SQL Server

Hi. Im just starting to learn Microsoft Visual Basic .Net, I'm having problem connecting to Microsoft Sql Server for the sample database Northwind. I can see SQL Server Service Manager on my taskbar but not connected. Please help thanks.
Chris,[vbcol=seagreen]
Whats the error?
Dinesh
SQL Server MVP
--
SQL Server FAQ at
http://www.tkdinesh.com
"Chris" <anonymous@.discussions.microsoft.com> wrote in message
news:3E1B5EE1-9707-46D7-8142-B9264FD52ABC@.microsoft.com...
> Hi. Im just starting to learn Microsoft Visual Basic .Net, I'm having
problem connecting to Microsoft Sql Server for the sample database
Northwind. I can see SQL Server Service Manager on my taskbar but not
connected. Please help thanks.
|||...this is the error. Test Connection Failed because of an Error in initializing provider. [DBNETLIB][COnnection Open(Connect()] SQL Server does not exist or Access Denied. I hope you could help me!!!
|||Chris,
See if its due to any of the scenarios mentioned in the below article:
'Potential causes of the "SQL Server Does Not Exist or Access Denied" error
message'
http://support.microsoft.com/?id=328306
Dinesh
SQL Server MVP
--
SQL Server FAQ at
http://www.tkdinesh.com
"Chris" <anonymous@.discussions.microsoft.com> wrote in message
news:9F5AAE66-7434-4F9D-971B-B94733F9FF60@.microsoft.com...
> ...this is the error. Test Connection Failed because of an Error in
initializing provider. [DBNETLIB][COnnection Open(Connect()] SQL Server does
not exist or Access Denied. I hope you could help me!!!

Connecting to Microsoft SQL Server

Hi. Im just starting to learn Microsoft Visual Basic .Net, I'm having proble
m connecting to Microsoft Sql Server for the sample database Northwind. I ca
n see SQL Server Service Manager on my taskbar but not connected. Please hel
p thanks.Chris,
Whats the error?
Dinesh
SQL Server MVP
--
--
SQL Server FAQ at
http://www.tkdinesh.com
"Chris" <anonymous@.discussions.microsoft.com> wrote in message
news:3E1B5EE1-9707-46D7-8142-B9264FD52ABC@.microsoft.com...[vbcol=seagreen]
> Hi. Im just starting to learn Microsoft Visual Basic .Net, I'm having
problem connecting to Microsoft Sql Server for the sample database
Northwind. I can see SQL Server Service Manager on my taskbar but not
connected. Please help thanks.|||...this is the error. Test Connection Failed because of an Error in initial
izing provider. [DBNETLIB][COnnection Open(Connect()] SQL Server doe
s not exist or Access Denied. I hope you could help me!!!|||Chris,
See if its due to any of the scenarios mentioned in the below article:
'Potential causes of the "SQL Server Does Not Exist or Access Denied" error
message'
http://support.microsoft.com/?id=328306
Dinesh
SQL Server MVP
--
--
SQL Server FAQ at
http://www.tkdinesh.com
"Chris" <anonymous@.discussions.microsoft.com> wrote in message
news:9F5AAE66-7434-4F9D-971B-B94733F9FF60@.microsoft.com...
> ...this is the error. Test Connection Failed because of an Error in
initializing provider. [DBNETLIB][COnnection Open(Connect()] SQL Ser
ver does
not exist or Access Denied. I hope you could help me!!!

Sunday, March 11, 2012

connecting to database in runtime using visual basic 6

hi;
i design a crystal report outside visual basic 6. what i did is just calling the crystal report filename. how can i change the source database of my crystal reports in runtime. im using microsoft sql server. the two database had the same table structure.
thanksWhich version of CR are you using?
If it is CR9 then
cr.Database.LogOnServer "p2ssql.dll", "Server", "Database", "UserName,"Password"

Friday, February 10, 2012

Connect to SQL Server 2000 with VB.NET for Beginners

I just started to learn Visual Basic 2005.NET. I have experience with VBA in Access and SQL Server.

I now want to build applications (client/server) with VB & SQL Server. Does anyone have a simple example with which I can start learning?

Thank you in advance!

There are many samples at the Microsoft download center. They are based either on Access or SQL Server and either on C# or VB.NET.

HTH, Jens Suessmeyer

http://www.sqlserver2005.de
|||

hi

Are your programming a windows based application or an ASP (web based) application?

joey

|||Hi Joey,

not an ASP, just a client/server application.

let's keep it simple. I'm just starting......