If StrSQL4 = " SELECT * FROM Spares =(Spares.stock) WHERE [SparesID] = " & TextBox1.Text & " " Then
con.Open()
Dim com10 As New OleDbCommand(StrSQL4, con)
Dim da As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
com10.ExecuteNonQuery()
ds = New DataSet
da = New OleDbDataAdapter(com10)
ds.Clear()
da.Fill(ds, "SparesID")
MessageBox.Show("Stock ไม่พอจ่าย", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim dtAdapter As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString,strSQL As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& _
Server.MapPath("database/mydatabase.mdb")&";Jet OLEDB:Database Password=;"
strSQL = " SELECT * FROM WHERE [SparesID] = " & TextBox1.Text & " "
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
dt = ds.Tables(0)
IF dt.Rows(0)("stock") < จำนวนที่สั่ง Then
MessageBox.Show("Stock ไม่พอจ่าย", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Error)
End IF
dtAdapter = Nothing
objConn.Close()
objConn = Nothing