User-1778072624 posted
How can I get the autonumber inserted in an access table, after a table is populated through an asp.net web form and display it in the form after it is brought up.
Public Sub btn_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
Try
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\Work\Documents\Visual Studio 2010\Projects\Websites\WebSiteJun25\App_Data\directcost.mdb;")
Dim cmd As New OleDbCommand()
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = "INSERT INTO tbPO(PODate,ShipTo,SupplierName,SupplierID,DateNeeded,ProjectCode,Type,InspComplete,Status,InvRec,InvTotal,POTotal,SubmissionComplete,ShippingInstr,PartialShip,Purpose,BuildID,Originator,BasicType) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
cmd.Parameters.AddWithValue("@varPODate", CDate(varPODate))
' cmd.Parameters.AddWithValue("@varSalesRep", varVendorContact_ID)
cmd.Parameters.AddWithValue("@varContact", DropDownList4.Text)
etc. etc
cmd.Connection = cn
cn.Open()
cmd.ExecuteNonQuery()
MsgBox("Record inserted successfully.")
cn.Close()
Catch st As Exception
MsgBox("Exception is " & st.Message)
End Try
Response.Redirect(Request.Url.ToString())
End Sub