
and a database as shown below:

It is an inventory program I am doing on the side just to keep track of a small number of supplies, I want to be able to enter a barcode and have the program see if it already is in the inventory database, if not, it will allow me to enter information and add it to the database (That part works - Thanks to member on D.I.C.)
If the barcode exists, I want it to fill the form with all the data from the database and allow me to update fields such as date used and used definition
Here is what I have so far:
Imports System
Imports System.IO
'Added For Database
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Dim SerialCallLogDatabaseLocation As String = "c:\database1.mdb"
Dim SerialCallLogTableName As String = "Table1"
Dim SerialCallLogDatabaseName As String = "Database1"
Dim Serialinc As Integer
Dim SerialMaxRows As Integer
Dim Serialcon As New OleDb.OleDbConnection
Dim Serialds As New DataSet
Dim Serialda As OleDb.OleDbDataAdapter
Dim Serialsql As String
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
'Entry
Dim Serialcb As New OleDb.OleDbCommandBuilder(Serialda)
Dim SerialdsNewRow As DataRow
Try
SerialdsNewRow = Serialds.Tables(SerialCallLogDatabaseName).NewRow
SerialdsNewRow.Item("ID") = txtBarcode.Text
SerialdsNewRow.Item("InvoiceNumber") = txtInvNum.Text
SerialdsNewRow.Item("OrderNumber") = txtOrdNum.Text
SerialdsNewRow.Item("InvoiceDate") = txtInvDate.Text
SerialdsNewRow.Item("ItemDescription") = txtItem.Text
SerialdsNewRow.Item("ItemCost") = txtCost.Text
SerialdsNewRow.Item("DateUsed") = txtDateUsed.Text
SerialdsNewRow.Item("OfficeUsed") = txtOffice.Text
SerialdsNewRow.Item("SerialNumber") = txtCompSer.Text
SerialdsNewRow.Item("UsedDefinition") = txtHowUsed.Text
SerialdsNewRow.Item("UPCIfThere") = txtUPC.Text
SerialdsNewRow.Item("SerialNumberIfThere") = txtSerNum.Text
Serialds.Tables(SerialCallLogDatabaseName).Rows.Add(SerialdsNewRow)
Serialda.Update(Serialds, SerialCallLogDatabaseName)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
'Reset
txtBarcode.Clear()
txtInvNum.Clear()
txtOrdNum.Clear()
txtInvDate.Clear()
txtItem.Clear()
txtCost.Clear()
txtDateUsed.Clear()
txtOffice.Clear()
txtCompSer.Clear()
txtHowUsed.Clear()
txtUPC.Clear()
txtSerNum.Clear()
txtBarcode.Focus()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Connect
Serialcon.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = " & SerialCallLogDatabaseLocation
Serialcon.Open()
Serialsql = "SELECT * FROM " & SerialCallLogTableName
Serialda = New OleDb.OleDbDataAdapter(Serialsql, Serialcon)
Serialda.Fill(Serialds, SerialCallLogDatabaseName)
Serialcon.Close()
SerialMaxRows = Serialds.Tables(SerialCallLogDatabaseName).Rows.Count
Serialinc = -1
End Sub
Private Sub btnLookup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLookup.Click
Dim SerNum As String
Dim NumRec As String
Dim BarSql As String
SerNum = txtBarcode.Text
If IsNumeric(SerNum) And SerNum.Length = 6 Then
Serialcon.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = " & SerialCallLogDatabaseLocation
BarSql = "Select Count(*) from " & SerialCallLogTableName & " Where ID = " & SerNum
Dim cmd As New SqlCommand("Select Count(ID) from " & SerialCallLogTableName, New SqlConnection(Serialcon.ConnectionString))
'ERROR! in above line
'This is where I get "Keyword not supported: 'provider'" when I press the lookup button
cmd.Connection.Open()
NumRec = cmd.ExecuteScalar
If NumRec = 0 Then
MsgBox("Item Does Not Exist", MsgBoxStyle.Information, "New Item")
Return
Else
MsgBox("Item Exists", MsgBoxStyle.Information, "Database")
'This is where I want to fill in form
'so for example, if I enter barcode 300252
'it will look for ID = 300252 and if it exists, it will
'pull InvoiceNumber from database and put it in txtInvoice
'(like txtInvoice.text = data(InvoiceNumber)
End If
End If
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
'This is where I want to be able to update the data in the dataset with any changes
'from the lookup command above
'so for example, I lookup barcode 300252
'it pulls the invoice number from barcode 300252 and puts it in txtInvoice
'I change the invoice number (say from 3008845 to 3238854)
'I hit "update", it saves the new invoice number to barcode 300252
End Sub
End Class
As you can see by my comments, Im running into a few snags.
Any and all suggestions are appreciated
Thank you in advance
-Josh

New Topic/Question
Reply




MultiQuote




|