Home
Privacy Policy
Friday, July 10, 2015
Connecting To A SQL Server Database Using ADODB
8:48 PM
Unknown
No comments
but this in a modul
Option Explicit Public Rsg As ADODB.Recordset Public con As ADODB.Connection Public ServerName As String Public LoginName As String Public LoginPassword As String Global DBNm As String Public strSQL As String Sub ATCONN() LoginName = "sa" LoginPassword = "2583094" DBNm = Text1 ServerName = Text2 Set con = New ADODB.Connection If con.State = 1 Then con.Close con.Open ("uid=" & LoginName & ";pwd=" & LoginPassword & ";server=" & ServerName & ";" & "driver={SQL Server};database=" & DBNm & ";") con.CommandTimeout = 0 If con.State <> adStateOpen Then MsgBox "no connection!" End End If Set Rsg = New ADODB.Recordset If Rsg.State = 1 Then Rsg.Close With Rsg .ActiveConnection = con .CursorLocation = adUseClient .CursorType = adOpenKeyset .LockType = adLockOptimistic Rsg.Open strSQL End With End Sub
Now you can Execute any SQL statement in vb 6 by this way:
strsql="select * from YOUR_TABLE"
atconn
and also you can make many connection with any other name to call sql statement
THANK YOU :)
Posted in:
Newer Post
Older Post
Home
0 comments:
Post a Comment
Subscribe to our RSS Feed
Be Our Fan on Facebook
Share
Popular
Tags
Blog Archives
Popular Posts
About Me
Unknown
View my complete profile
Powered by
Blogger
.
Blog Archive
▼
2015
(3)
▼
July
(3)
Edit data in msflexgrid vb6
Connecting To A SQL Server Database Using ADODB
Formating dates and times in VB6
Blog Archive
▼
2015
(3)
▼
July
(3)
Edit data in msflexgrid vb6
Connecting To A SQL Server Database Using ADODB
Formating dates and times in VB6
0 comments:
Post a Comment