How am i going to insert data into my database table using sql statement.??? I'm currently on a project using ODBC to access my daatbase....Please enlighten mi...my data include 5 string data and one integer data...
as liziyu sugested, ado is the way to do it..
a quick tutorial:
There are 2 libraries you could use for this:
Microsoft ActiveX Data Objects (version) Library
or
Microsoft ActiveX Data Objects Recordset (version) Library
The first is a complete set of objects (ADODB) the second is a simplified verion (ADOR)
My example uses the first library.
--CODE--
'Needed ADODB objects
Dim oRs As ADODB.Recordset
Dim oCon As ADODB.Connection
'Needed strings
Dim strSQL As String
Dim ConnString as String
ConnString = "Provider=MSDASQL.1;Persist Security _
Info=False;User ID=admin;Data Source=ODBCNAME"
strSQL = "INSERT INTO Name _
SELECT a.id, a.name, use _
FROM 3Name a, 3ReplaceCompanyid b _
WHERE a.companyid = b.id"
'Preparations (making the connection,..)
Set oCon = New Connection
oCon.ConnectionString = ConnString
oCon.Open
Set oRs = New Recordset
oRs.CursorLocation = adUseClient
'Here's where you actually perform the SQL
oRs.Open strSQL, oCon, adOpenKeyset, adLockBatchOptimistic
'clean up
Set oRs.ActiveConnection = Nothing
Set oCon = Nothing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.