|
-
Sep 26th, 2007, 06:10 AM
#1
Thread Starter
New Member
Connect VB6 to SQL 2005
Hi All
I am using vb6 and sql server 2005. I’m trying to connect to a database obviously from vb6. I got some code from the net which is
vb Code:
'Declaring your database
Public MyDatabase As ADODB.Connection
'Tables into your database
Public MyTable1 As ADODB.Recordset
Private Sub Form_Load()
'Set your variables to nothing (just for stability)
Set MyDatabase = Nothing
Set MyTable1 = Nothing
'Connecting to your DB
Set MyDatabase = New ADODB.Connection
Set MyTable1 = New ADODB.Recordset
'Here's where you're to set all your database options
ConnectionString = "Provider=SQLOLEDB.1" _
& ";User ID=YOUR-E50BC0DF75\nick" _
& ";Password=" _
& ";Initial Catalog=vb6sql" _
& ";Data Source=xxx.x.x.x\YOUR-E50BC0DF75\SQLEXPRESS"
'If your database is in another computer in the local network you can replace 127.0.0.1 with it's ip adress
MyDatabase.Open ConnectionString
MyTable1.CursorLocation = adUseClient
End Sub
Now I tried running it but get the message
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’� ��’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
Run-time error ‘-2147467259 (80004005) ‘:
[DBNETLIB][ConnectionOpen(Connect()).]SQL Server does not exist or access denied.
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’� ��’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
I don’t know whether I have got a password or not and if I have I don’t know it. I created the database vb6sql just to test the connection. This is all new to me so if someone could explain in easy to understand step’s I would really appreciate it.
Regards
Nick
Last edited by Hack; Sep 26th, 2007 at 06:20 AM.
Reason: Added Highlight Tags and Removed IP Address
-
Sep 26th, 2007, 06:25 AM
#2
Re: Connect VB6 to SQL 2005
Moved to database development
Welcome to the forums. 
I edited your thread and added [highlight=vb]your code goes in here[/highlight] tags for better readability. In addition, I don't know whether the IP address you entered was real or not, but just in case it was real, I removed it. You never want to use a real IP address in an open forum thread.
Questions:
1. If you created the database, how can you not know whether there is a password?
2. Are you sure the ip address and database name is correct?
3. Is it setup for remote connections?
4. Do you have a namespace with tables under it called vb6sql?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|