Dim objConn As System.Data.OleDb.OleDbConnection
Dim objCmd As New System.Data.OleDb.OleDbCommand
Dim ds As New DataSet
Dim sa As OleDbDataAdapter
Dim g As Integer
Dim strConnString, strSQL, strSQL1 As String
Dim xlBook As Excel.Workbook
Dim xlApp As New Excel.Application
Private Sub Connopen()
strConnString = "provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Documents and Settings\akasit\Desktop\STK\STK\STK\Computer1.xlsx; Extended Properties=Excel 12.0;"
objConn = New OleDbConnection(strConnString)
objConn.Open()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Connopen()
g = 0
strSQL = "select max (SKU_KEY) FROM [Data$]"
objCmd = New OleDbCommand(strSQL, objConn)
g = objCmd.ExecuteScalar
g = g + 1
strSQL = "INSERT INTO [Data$] (SKU_KEY,SKU_CODE,SKU_NAME,SKU_QTY,SKU_TYPER,DI_DATE_TIME,DI_USER) " & _
"VALUES ('" & g & "','" & TextBox1.Text & "','" & ComboBox1.Text & "'," & _
"'" & TextBox3.Text & "','307','" & Now.Date & "','" & Login.LogUSR.Text & "')"
objCmd = New OleDbCommand(strSQL, objConn)
objCmd.CommandText = strSQL
objCmd.ExecuteNonQuery()
MsgBox("บันทึกสำเร็จ")
objConn.Close()
End Sub