Partial Class findItem
Inherits System.Web.UI.Page
Public searchResult As DataTable
Public keyStr As String
Dim con As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\findItem.accdb;Persist Security Info=False;"
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
'keyStr = Request.QueryString("keywordTxt")
keyStr = Request.Params("keywordTxt")
If keyStr Is Nothing Then
keyStr = ""
End If
Dim oper As String
oper = Request.QueryString("oper")
If oper Is Nothing Then System.Diagnostics.Debug.WriteLine("no oper")
ElseIf oper = "pingHardware" Then System.Diagnostics.Debug.WriteLine("pingHardware")
Dim itemId As String = Request.QueryString("itemId") System.Diagnostics.Debug.WriteLine("pingHardware itemId " + itemId)
Dim conn As New OleDbConnection(con)
conn.Open()
Dim cmdd As New OleDbCommand("SELECT * FROM ItemPlace WHERE ID=@ItemId ORDER BY ItemId ASC", conn) cmdd.Parameters.AddWithValue("@ItemId", itemId)
searchResult = New DataTable() searchResult.Load(cmdd.ExecuteReader())
keyStr = searchResult.Rows(0).Item("ItemName").ToString() System.Diagnostics.Debug.WriteLine("pingHardware Keyword " + keyStr)
pingHardware(searchResult.Rows(0).Item("Department").ToString, Integer.Parse(searchResult.Rows(0).Item("Shelf").ToString))
conn.Close()
End If
System.Diagnostics.Debug.WriteLine("key " + keyStr)
'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\database1.accdb;Persist Security Info=False;
'Dim con As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\databasename.accdb;Persist Security Info=True;Jet OLEDBatabase Password=123;"
'Dim con As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\findItem.accdb;Persist Security Info=False;"
Dim conec As New OleDbConnection(con)
conec.Open()
Dim cmd As New OleDbCommand("SELECT * FROM ItemPlace WHERE (ItemName LIKE '%' + @keyword + '%') ORDER BY ItemId ASC", conec)
cmd.Parameters.AddWithValue("@keyword", "%" + keyStr + "%")
searchResult = New DataTable()
searchResult.Load(cmd.ExecuteReader())
'Dim adapter As New OleDbDataAdapter("SELECT * FROM ItemPlace WHERE ItemName LIKE ORDER BY ID ASC", conec)
'Dim dataSet As New DataSet("testDataSet")
'adapter.Fill(dataSet)
'searchResult = dataSet.Tables(0)
System.Diagnostics.Debug.WriteLine("resultSize " + searchResult.Rows.Count.ToString())
conec.Close()
End Sub
Protected Sub pingHardware(ByVal department As String, ByVal shelf As Integer)
'ไปใช้ที่ viewItem แทน
'System.Diagnostics.Debug.WriteLine("Write code to hardware here !!!")
'System.Diagnostics.Debug.WriteLine("Write code to hardware here !!! " + department + "," + shelf.ToString)
End Sub
End Class[font=Verdana][/font]