Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How To Connect VB 6.0 With SQL Server

Hi friends! i'm new in your group and i need your help.Actually i want to connect VB 6.0 applications with SQL and i'm not able to do it.Please help me as early as possible.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Start Sql 2000 Server On Server Machine And Connect To Its Clients Via VB 6.0
how to start sql 2000 server on server machine and connect to its clients via VB 6.0 ...?

Error 8447 Internet Server Error When Trying To Connect To Access DSN On My Server
I'm trying to connect my vb6 application to a Access database located on my server...

I created a system DSN on my server for my Access db

I used the following code and it gives me an error ( '8447' Internet Server Error ), it is also the same error it gave me when I tried to use the code at the following post...

code :

Private Sub Command1_Click()
Dim rsGeneric As ADODB.Recordset
Dim cnnGeneric As ADODB.Connection
Set cnnGeneric = New ADODB.Connection
cnnGeneric.Open "Provider=MS Remote;" _
    & "Remote Provider=MSDataShape;" _
    & "Remote Server=;" _
    & "Data Source=Alert;" _
    & "User Id=test;Password=test;"
Set rsGeneric = New ADODB.Recordset
With rsGeneric
    .CursorLocation = adUseClient
    .Open "SELECT * FROM Livratemps", cnnGeneric
    .ActiveConnection = Nothing
End With

End Sub

the bold line is where the error is generated...

I think it's because I don't have my RDS set up...
Well, I don't know what is RDS...
Can somebody tell me what I have to do to activate RDS and get this code working...
Thanks a lot!!

Edited by - acad on 7/11/2003 7:49:49 AM

OPC Server Connect
I'm using an OPC Server to communication with a PLC and I'm having a little problem the very first time the program runs after a reboot of the system. It takes a little while for the OPC Server to connect therefore if I try to do anything beforehand, the program shuts down with the following error:


PCU.exe has generated errors and will be closed by Windows. You will need to restart the program.

An error log is being created.

i've also tried using delays, but they dont seem to work right for me in this case.

I have put in commands for picking up errors before, but I can't seem to trap this there some special way to watch for the above error?

oh yeah, i can't seem to find the error log

Thanks a million for any info


Connect To An Irc Server...
i im trying to make an ocx that connects to servers.

i used winsock and tried to connect it to

i've tried the command
winsock.Connect "", 6667
but it doesnt work
can winsock connect to a server by the name? or it needs the ip?


that is some special info that i can send to irc so he can accept my connection ?


Connect To Msn Server
How can i connect to the msn server ( )
I want to make my own messenger wich loads the people i have in my list into my own app.

Connect To MDB On Web Server - VB6

I had to create a program using VB, which is used to alter information in a Microsoft Access Database and also create a website, which is used to present the information in the database.

I've done this, but the method I've used involves the database being stored within the same location as where the program is running from or in a sub folder within the same directory as where the program is running from and the website requires the database be stored on the web server, in which it's being hosted from, so the only option I have is to alter the connection string to point to the database hosted on the web server, although sadly it doesn't seem to be as simple as that.

Background Info...

Web Server...
Windows XP Pro
Password Login
Running IIS
Scripts have been allowed on the directory in which the website and database is being hosted from.
Read and Write Access has been allowed for Web Users.
The directory is also shared for other Network users.

The database isn't password protected.

The closest I've got is connecting to the Database via another PC on the network and have had successful results, with the changes immediately taking effect on the website.

I've read somewhere that it used to be possible, but the functionality has now been taken away, due to the method being so in-secure, but why take the functionality away, when they could have simply informed of the security issues and allowed people to decide if they wish to take the risk.

Can anyone inform me otherwise?



Connect To Db On Ftp Server
I know how to connect to my database when on my hard drive.

I just uploaded it to an ftp there a way to connect to it?

SOmething like:

Set dbdist = DBEngine.OpenDatabase("ftp://mydatabase.location")?

Can someone help me out?


Connect To A SQL-Server Via DNS
Hi guys!

I hope this wasnt already a problem here, but it is a little difficult to perform a search with "dns" (4 letters are minimum)

Well, i can connect to any sql-server and its database with a non-dns-code:

Private Sub Form_Load()

Dim adoConn As New adodb.Connection
Dim adoRS As New adodb.Recordset
Dim sqlString As String

' The connection string
adoConn.ConnectionString = "Driver={SQL Server}; " & _
"Server=SQLSrv; " & _
"Database=MyDataBase; " & _
"UID=admin; " & _

' The sql statement
sqlString = "SELECT dbdatetime FROM dwsys"

On Error Resume Next
'Open the whole thing

adoRS.Open sqlString, adoConn, adOpenKeyset, adLockPessimistic, adCmdText

' Do something here ...

adoRS.Close ' ... and disconnect again

Set adoRS = Nothing
Set adoConn = Nothing
End Sub
How can i connect to the same server via DNS??

Greets and thanks in advance!

Not Connect To SQL Server(DSN/DSN Less)
I have installed SQL 2000 just now. when i am connection to SQL
server using DSN or DSN Less to VB or ASP the following error is occuring and its not
connecting to SQL Server.
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E4D)
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'DS3IUSR_DS3'.
I have check the login name and password its OK. but it steel shwos the
same error.

Help me Please.


Can't Connect To SQL Server!

I'm developing an application with VB 6 & SQL Server 7.0. My problem occurs when the application is running on a client machine.

I setup the ODBC connection and run my application. TCP/IP is used in Network Library to connect to SQL Server. When I try to connect to the DB thru the application, an error message prompt:

[Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL server not found.

While in another machine, where SQL Server client is installed, does not have this problem. Both workstations are running Win 2K prof SP3.

Does anyone have this experience and can help me??


How To Connect To SQL Server
i finished building up a forum with vBulltin Board
Howerver..I want to connect it to a database which i had restored?
How can I do that/

Connect To SQL Server?
i wanted to know if i can connect to a SQL sevrer and and use that as ur database with ADO or whatever. cause i have a webserver that has SQL, and i wnated to know if i can use that?


Connect To SQL Server Through VB
Hi there,
I have been trying to connect to my sql 7 server for a while now, no luck. Im just starting out, but this is what I have so far, and I can't seem to pull anything up.. The Server is behind a firewall so don't mind the generic password.

My eventual goal is to make small programs that run one query at the click of a button, this is for employee useage really. I just wanted a small form to allow the entry of a ID then click the button, and run the query/update on the ID the employee entered. But I can't get a simple query to return anything yet. Any takers?


Private Sub Command1_Click()
Dim query As String
Text1.Text = "query"
End Sub

Private Sub Form_Load()

Dim GEXCONN As String

GEXCONN = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=bb50;Data Source="

End Sub

How To Connect To SQL Server?
I don't know anything about SQL Server. Please help me.

I am writing a program to pull data from tables in SQL server and dump into MS Access database.

How to connect to SQL Server using VB6 codes?
How to query the records out so I can save to Access db?

Connect VB With SQL Server !!
hi for every one
i have SQL Server database and i want to connect with visual basic forms
because i want to query about specific data from some tables
and i want to use the forms to do that

1- how can i connect vb with SQL Server?
2- how can i show records for some tables?
for exampl:
i use Data component when i connecting with access and i can see any records from any table in database .
what componenet can i use with SQL Server

thank you .

Connect To MSN Server :D
Hi all,
Does anyone know how to connect to the MSN server via Sockets(I think thats what it is called) via VB6?

I have downloaded some examples from and they dont work

Connect To Server
i am having an client-server application.
some of my text files are on server.
and exe running on client machine has to access that files on server.
now the problem is that , server has password and i do not want to leak a server passwrod to my users.
but for my application, user must access server and give its password as i mapped server's folder to user's local machine.
i want to find vb-code such that i will give password by my coding only,
no user will require to enter password of server to access server.
pls if anyone knows tell me solution.

Connect To Ms SQL Server DB !
any wizard help to connect to the database in vb6? vb .net does hav wizard help in connecting to database. feels strange suddenly go backward.

How To Connect To A Web Server?
Hello there,

I have an SQL server residing on an ISS server. I want my vb program to connect to SQL Server using the IIS. By this way using the internet my vb program can connect to the database residing in the IIS server.

How can i possibly do this. Pls Help.

thanks a lot.

Connect To SQL Server
Anyone know where I can find some good documentation on how to connect to
SQL Server via Visual Basic or have some feedback?

Thanks in advance,

Connect To SQL Server Through VBA
Could someone help me connect to and execute a query to Sql Server with VBA?  

Thanks alot,


How To Connect A SQL Server DB To
Could someone help me doing that? I've really searched a lot but i haven't find anything that can help me.

Connect To Sql Server

How i can connect my application to Sql Server database?

Thanks in advance

Connect To .dbf On Ftp Server
i wanna connect to dbf file on my ftp server so...

Set Con = New ADODB.Connection
Set Rec = New ADODB.Recordset
Dim Sql As String
Sql = "SELECT * FROM data.dbf"
Con.Open "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & _
"Dbq=;", UserID = xxx, Password = xxx
Rec.Open Sql, Con, adOpenStatic, adLockOptimistic

and i have error login (8000405)

what i doing wrong

Best Way To Connect To SQL Server
Hello all. Here is how I currently connect to my SQL server which has been working for many months but today it can not connect and I do not know why so I am looking for a better way.

gConnect.ConnectionString = "driver={SQL Server};server=;uid=(userid);pwd=(the password);database=hr"

Now all I get is a timeout. Except once in a great moon it does connect.

Please help!!!





[DBNELIB][ConnectionOpen(Connect()).]SQLServer does not exist or access denied

I have installed latest MDAC but....

I don't know if this has something do.. the SQL Server on which it is installed has different IP Series. for eg the server is installed in and system from where i am trying is



[DBNELIB][ConnectionOpen(Connect()).]SQLServer does not exist or access denied

I have installed latest MDAC but....

I don't know if this has something do.. the SQL Server on which it is installed has different IP Series. for eg the server is installed in and system from where i am trying is

Thread locked coz of double posting, will be continued here

Edited by - vikramjb on 2/9/2006 2:43:40 AM

Connect To SQL Server

I use the following code to craete conection to Access database:

Dim objConn
set objConn=Server.CreateObject ("ADODB.Connection")
objConn.ConnectionString ="DRIVER={Microsoft Access Driver(*.mdb)};" & "DBQ="S:TmpProjectsWebTest1.mdb"

How can I connect to SQL server 7.0 database?


How To Connect To Sql Server

Im trying to develop an information system using VB6.

Im really having a hard time connecting to a SQLSERVER 2000 database server on my network....

I've tried manipulating the datasource but to no avail.... If anyone can help me by showing some example please do...

i would really appreciate your help...


Connect To Ftp Server Using VB
Hello I am doing an asp application as front end and client wants the backend of the application should be a stand alone client.So i have planned to do that using visual basic which i know best.

I need experts clarficatioins that is it possible to connect a database in ftp server using visual basic 6?

FTP SERVER --- Sql Server -- ODBC<-

Client Machine -- vb application - |

if yes, then how to do the connection string

thanks and regards

Connect SQL Server 7.0 From VB
I want to connect to SQL Server 7.0 from VB 6.0 with parameter passing concept i.e. with the concept of Database server and Application server. Can anyone help me with the piece of code...


Connect SQL Server
Dear friends,
I'm a programmer with VB in front end and Oracle
backend..I worked in a hospital management software before..The project was completed with the concept of parameter passing from frontend to backend and backend to frontend..with Oracle and VB...The database connection part was done by my senior...Now I could not connect Vb with SQL Server 7.0...Can anyone of you help me with some piece of code which connects Vb with SQL Server....(passing parameter)


Server Not Connect
In Crystal Report I have to design my Report with Connection to my Database via ADO and OLEDB.
Now if i run my VB-Prog, which displays different Reports dynamically during runtime. I get the Error Message :"Not connect with Server" or I have to Connect do my Database and Server for each table of the Database I use manually (and my reports use a lot of Tables). Does anyone know a possibilty to Connect with my Database-Server only once and automatically?



P.S I'm using MS SQL 7

Connect To SQL Server
Hi Babu,
I have a file (.rpt) that designed in Crystal Report. I have a project in Visual Basic that connect to database SQL Server.
Example :
In Module:

Public cn as ADODB.Connection
Public Function Connect() '(ServerIP As String, Username As String, Password As String, Database As String) As Integer
On Error GoTo Label
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=SQLOLEDB.1;DataSource =;Initial Catalog=Quanlybaobi;User Id=sa;Password=;"
cn.CursorLocation = adUseClient
If cn.State = 0 Then
Msgbox " "
Msgbox " "
End If
Exit Function
Msgbox " "
End Function

In Form :

With CrystalReport1
.ReportFileName = ".CR_Thu.rpt"
.Connect = "Provider=SQLOLEDB.1;DataSource =;Initial Catalog=Quanlybaobi;User Id=sa;Password=;"
.Destination = crptToPrinter

If .RecordsPrinted = 0 Then
AppActivate .WindowTitle
SendKeys "%{F4}", True
MsgBox " "
End If
End With

Is the command CrystalReport1.Connect correct?
Give me a advice. Thank you very much.

Server Connect Problem
Not sure if this is the right place to post this, but...

I have used VB to create a program for one of our customers. With the program, the customer firm can check their cases status , witch are in a SQL-DB on the server of my company. I use ADODB to connect, and specify the HTTP adress. This works fine, but the client has a firewall running that is preventing them from getting access. Is there any way I can specify a port to connect through...??? Hope someone can help.

Connect Excel To MS SQL Server
Hi All,

I have a problem here. Currently I am involve with a project which will generate a report with Crystal Report 11 and at the same time, need to populate those data into a temporary table in MS SQL Server 2005.

User will have an excel file which will connect and retrieve all the data in the temporary table everytime they choose to view it. Does anyone have any idea on how to connect excel file to MS SQL Server 2005? Appreciate if anyone can give me some hints. Thanks.

How To Connect SQL Server Database In VB
I creat a Database GSM in SQL Server 7.0,but I can't open it in VB.
for example:
Conn = "UID = admin;PWD = 1234;DATABASE = GSM;" & "SERVER=PDCOFMTL;DRIVER={SQL Server}"
Set myEn = rdoEngine.rdoEnvironments(0)
Set myCon = myEn.OpenConnection("", rdDriverNoPrompt, False, Conn)
It always reportata Source Name not fount and no default driver specified.
Why ?

Connect To Internet Or Ftp Server...
I have basic vb programming skills. I am just wondering how i can access an ftp server from my program. Do i use activeX or can i write it in my form... Is there another program that i need to access to get on-line?


Using ADO To Connect To A Win2K Server
Well, the answer may be staring me in the face but.....

I have a small application for generating reports. It's only accessed over our company network and I use the IP address of the desktop PC as a validation as to whether or not that PC is authorised to view the Word docs. On a WIn2K server, I keep a list of authorised IPs. If they match, the user can open the doc...otherwise not.

If I have an account on the "DBUtil" machine, this extract of code works fine........

cnn.Provider = "Microsoft.Jet.OLEDB.4.0"
cnn.Properties("Data Source") = "\DBUtildatabasesM_Reports.MDB"

Set rst = New ADODB.Recordset
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open "tbl_IP", cnn, , , adCmdTable

With rst
.Find "[IPAddress]='" & strIP & "'"
If .EOF = False Then 'Found
GoTo KeyCheck:
MsgBox "Unauthorised user or incorrect KeyWord"
Exit Sub
End If
End With

Set rst = Nothing
Set cnn = Nothing

....problem is, someone with no DBUtil account won't be able to have their IP credentials checked because of No Permissions.

I figure there has to be an easy way of passing a 'username' & 'password' to my Win2K machine when I make the Connection but I've searched near and far and can't make any headway!

Anyone been here before?


Connect To Sql Server Database
I'v been programming in Access for a while now, but I have a project now that requires me to use MS Sql Server and vb6.

the sqlserver is on the same drive as the vb appication. How do I connect to the sql database.

How To Connect To Sql Behind Proxy Server
hai I need to point to dsn to another dsn..

my problem is

I have to connect to the machine databse from my machine from that remote machine I need to connect to the databese in the another machine which is in LAN with the remotr machine..

1) my machine--->2)remote machine.......>3)machine in lan connected

from 1) to 2) I can connect to through dsn
from 2)to 3) have to connect ?..

I read someware that from dsn we can connect to another dsn ..

but I forgot where I read that articles.if any body knows please let me know..

Thanx in advance..

Connect To Sql Server Database
Does anyone know how to connect to an sql sever database that has a password and username on it.


Connect To MSDE Is The Same As SQL-Server?
Hi there,

There is two questions:

1) The connection string to MSDE is exactly the same as used to SQL Server?

2) Can anyone, please, post the correct string? I am asking it because I stayed looking around and found a Thinker post where he told something about OLE DB x ODBC where maybe there is a way to connect that's better than another (I guess that this matter is a kind of nebulous for me).

Thank you very much!

How To VB6 Connect To SQL Server Via Internet
Hi all,

Is there anyone in this forum can make a little tutorial on how VB6 connect to SQL Server through Internet. Any suggestion, ideas. I'm having trouble in connecting to MSSQL.

I have Win Server 2003, and SQL 2000 Enterprise.


Connect To Linux Server
please i need asap to know how to connect w/linux (firebird DB) from VB of course, through the network. anyone could help me? thanks in advance.

HOW TO Connect To SERVER DB Via VB Programme

I want to connect to database of my site ( from some little programme writed by me on VISUAL BASIC 6 to get some data about my users...

How can I do this? How to connect to DB from VB?

If it possible?

may be visual basic 2008 users can help me too...


Connect To Mysql Server With ADO In VB
Trying to connect to a Unix server running Mysql from VB 6. I continue to get error -2147467259 connection lost error when trying to add new records.
I can connect with ftp fine and connect to my local test enviornment with these settings, but not able to connect to the server. Any suggestions on the connection string below or other possibilities. The error occurs at Thanks.

Dim conn As ADODB.Connection
Set conn = New ADODB.Connection

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

conn.CursorLocation = adUseClient

conn.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};" & _
"Server=" & Server.Text & ";" & _
"Port=" & Port.Text & ";" & _
"Database=" & DB.Text & ";" & _
"Uid=" & UID.Text & ";" & _
"Pwd=" & Pass.Text & ";" & _
"Option=1 2 8 32 2048 16384;" '131072


Unable To Connect To SQL Server - Please Help
I have a bit of a frustrating problem here. I have developed an application that works with an SQL Server database. It is meant to run as client applications on a company intranet, accessing SQL Server on their server. I have installed SQL Server on their server, and it's working fine. I am able to connect to the server and run my program as it should if it is installed on the server. However, I am unable to connect to the server from any other computer, even though they are networked successfully to the server computer (e.g. are able to map drives to server drives, etc.)

I am wondering if the problem is in how I am connecting to SQL Server, or if I have failed to configure SQL Server correctly. I am running the MSDE version of SQL Server. The connection string I use when connecting locally (ie. client app is on server) looks like this:

Provider=sqloledb;Data Source=(local);
Initial Catalog=cas;
User ID=main;Password=;

This successfully gives me a connection. The connection string from a remote computer looks like this:

Provider=sqloledb;Data Source=\MOUAMOUA;
Initial Catalog=cas;
User ID=main;Password=;

Does that look right? Yes, the computer's name is MOUAMOUA, an inside joke at the office. When attempting to connect locally like this, I get an error code of -2147467259 (Server doesn't exist or is shut down). Providing the password I created for the DB in the connection string so it looks like this:

Provider=sqloledb;Data Source=\MOUAMOUA;
Initial Catalog=cas;
User ID=main;Password=password_here;

Does not make any difference. Various other things I have tried, like removing the slashes to create server name of "MOUAMOUA", have all failed. I have also tried some different settings with SQL Server, but I am unable to make this work...and I'm almost at my wits end! Please help me if you are able to do so. Thanks.

Connect To A SFTP (SSH) Server
Does anyone know any links to a good sftp (ssh) activex control? Can this be done in code through winsock control, etc too?


Copyright 2005-08, All rights reserved