Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection String 1

Status
Not open for further replies.

R9772

Technical User
Aug 15, 2002
76
US
can anyone help me with a connection to a SQL Server database?
 
Refer MSDN
In msdn direct code is there.
Just u copy that and paste ur application change the server name
 
drop a ADO Data control on your form, use the connection string property to build the connection string, then cut and copy the string and remove the control.
 
Or paste the following into a file with .vbs as extension. Double click the file and the datalink dialog will pop up.
The code was originally posted in an other forum - but I couldn't find it agian. I did not write this code.

********************************************************
Dim oDataLinks, sRetVal
set oDataLinks = CreateObject("DataLinks")
On Error Resume Next
sRetVal = oDataLinks.PromptNew
On Error Goto 0
If Not IsEmpty(sRetVal) Then
InputBox "Your Connection String Is Listed Below", "OLEDB Connection String", sRetVal
End If
Set oDataLinks = Nothing
********************************************************
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Try this out,

Step 1.
Dim strCon as string
Dim con as new ADODB.Connection

Step 2.
if you are using a DSN(Data source name) to connect to the SQL server, Then use this method

Syntax:
strCon="DSN=DSN_Name;UID=userID;PWD=password;Database=databasename"

Or you can use this method which is much easier,
Syntax:
strCon="DRIVER={SQL SERVER};SERVER=SERVER_Name;UID=userID;PWD=password;Database=databa"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top