I'm using asp.net in conjunction with the web matrix offered by MSFT to create page, basically so that anyone can add records. (Specifically new products) I'm a relative noobie and I can't seem to find my books, so I figure the next best place is the internet.
Function MyInsertMethod(ByVal part Number As String, ByVal manufacturer As String, ByVal category As String, ByVal description As String, ByVal link As Integer) As Integer
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Documents an"& _
"d Settings\Mike\My Documents\My Webs\myweb\db1.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "INSERT INTO [productlist] ([Part Number], [Manufacturer], [Category], [Descriptio"& _
"n], [Link]) VALUES (@Part Number, @Manufacturer, @Category, @Description, @Link)"& _
""
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_part Number As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_part Number.ParameterName = "@Part Number"
dbParam_part Number.Value = part Number
dbParam_part Number.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_part Number)
Dim dbParam_manufacturer As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_manufacturer.ParameterName = "@Manufacturer"
dbParam_manufacturer.Value = manufacturer
dbParam_manufacturer.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_manufacturer)
Dim dbParam_category As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_category.ParameterName = "@Category"
dbParam_category.Value = category
dbParam_category.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_category)
Dim dbParam_description As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_description.ParameterName = "@Description"
dbParam_description.Value = description
dbParam_description.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_description)
Dim dbParam_link As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_link.ParameterName = "@Link"
dbParam_link.Value = link
dbParam_link.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_link)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try
Return rowsAffected
End Function
</script>
<html>
<head>
</head>
<body text="black" vlink="blue" link="blue">
<form runat="server">
<p>
Enter New Products into the Database:
</p>
<p>
Manufacturer's Part Number:
<asp:TextBox id="Partnumb" runat="server"></asp:TextBox>
(The product number that the manufaturer uses)
</p>
<p>
Manufacturer Name:
<asp:TextBox id="Manufact" runat="server"></asp:TextBox>
(Devil Biss, Sherwin Williams, etc)
</p>
<p>
Category:
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
(Abrasives, Paint, Paint Guns)
</p>
<p>
Description of Product:<br />
<asp:TextBox id="Proddesc" runat="server" Width="461px" Height="77px"></asp:TextBox>
</p>
<p>
Link for product:
<asp:TextBox id="Link" runat="server"></asp:TextBox>
(<a disabled="disabled" href="http://www.sherwin-williams.com/arew_awe.pdf">http://www.sherwin-williams.com/arew_awe.pdf</a>)<br />
</p>
<p align="center">
<asp:Button id="Submit" runat="server" Text="Submit To Product Database"></asp:Button>
</p>
<!-- Insert content here -->
</form>
</body>
</html>
What do I need to do to add the values to that database? Any ideas?
Bookmarks