MS Access insert data in SQL Server
Option Compare Database
Private Sub Command27_Click()
Call GetDataFromADO
End Sub
Sub GetDataFromADO()
'Declare variables'
Set objMyconn = New ADODB.Connection
Set objMyCmd = New ADODB.Command
Set objMyRecordset = New ADODB.Recordset
Dim rc As Long
'Open Connection'
objMyconn.ConnectionString = "Provider=SQLOLEDB;Data Source=LAPTOP-0ACTJCP6\SQLEXPRESS;Initial Catalog=sinkydb; Integrated Security=SSPI;"
objMyconn.Open
Dim strsql
strsql = "insert into Tblinserdata(Fname, Lname, address) select '" & tbfname.Value & "','" & tbLname.Value & "','" & TbAddress.Value & "'"
Debug.Print strsql
objMyconn.Execute (strsql)
'Set and Excecute SQL Command'
objMyconn.Close
End Sub
No comments:
Post a Comment