Hi,
I need some code to Insert data from table in SQL to table in Access.
I'm using this code, but there is an error that I don't know how to fix, please show me how:
Code:Imports System.Data.OleDb Imports System.Data.SqlClient Imports System.Data Public Class ConvertDB Inherits System.Windows.Forms.Form Private cnn As New SqlClient.SqlConnection Private cmd As New SqlCommand Private ConnectionString As String Private sql As String Private str As String Private cmdd As New OleDbCommand Private iCount As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ConnectionString = "Server=ASUS;database=Titscompany;integrated security=SSPI;" MsgBox("Connection established") sql = "SELECT TEST_ID, TEST_NAME, TEST_DT, TEST_TYPE FROM TEST" Try cnn = New SqlConnection(ConnectionString) cnn.Open() cmd = New SqlCommand(sql, cnn) cmd.ExecuteNonQuery() cnn.Close() MsgBox("ExecutionNonQuery in SqlCommand executed") Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Try Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\TEST.mdb") cn.Open() str = "insert into TEST(TEST_ID, TEST_NAME, TEST_DT, TEST_TYPE) values (@TEST_ID, @TEST_NAME, @TEST_DT, @TEST_TYPE)IN 'D:\TEST.mdb' " 'IN 'D:\TEST.mdb' cmdd = New OleDbCommand(str, cn) iCount = cmdd.ExecuteNonQuery cn = Nothing MsgBox(iCount) Catch ex As Exception MsgBox("Error: " & ex.Source & " " & ex.Message) End Try End Sub
The Button1.Click function is OK, but the Button2.Click catch an error "Microsoft Jet Database Engine Missing Semicolon (at end of SQL statement"
Please help me.




at end of SQL statement"
Reply With Quote