Methodology
- From: "Mark A. Sam" <msam@xxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Mar 2006 14:33:47 -0500
Hello,
Thanks to members of this fourm, I was able to get this method to work to
write a record to an Access DB from the fields on a webform. I'd like to
know if this is current practice or is there something better to use, and
where can I find examples.
Thanks for your help and God Bless,
Mark
Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" + Server.MapPath("_database/DragonImporting.mdb")
Dim myConn As New Data.OleDb.OleDbConnection(connectString)
myConn.Open()
Dim strSQL As String = "INSERT INTO tblContactForm1 (txtName, txtCompany,
txtPhone, txtEmail, txtComments, chkGrower, chkProduceDealer,
txtOtherCustType, chkStandardBags, chkCustomBags,txtOtherBags) VALUES
(@txtName, @txtCompany, @txtPhone, @txtEmail, @txtComments, @chkGrower,
@chkProduceDealer, @txtOtherCustType, @chkStandardBags, @chkCustomBags,
@txtOtherBags)"
Dim myCmd As New Data.OleDb.OleDbCommand(strSQL, myConn)
myCmd.Parameters.Add("txtName", Data.OleDb.OleDbType.VarChar).Value =
txtName.Text
myCmd.Parameters.Add("txtCompany", Data.OleDb.OleDbType.VarChar).Value =
txtCompany.Text
myCmd.Parameters.Add("txtPhone", Data.OleDb.OleDbType.VarChar).Value =
txtPhone.Text
myCmd.Parameters.Add("txtEmail", Data.OleDb.OleDbType.VarChar).Value =
txtEmail.Text
myCmd.Parameters.Add("txtComments", Data.OleDb.OleDbType.VarChar).Value =
txtComments.Text
myCmd.Parameters.Add("chkGrower", Data.OleDb.OleDbType.Boolean).Value =
chkGrower.Checked
myCmd.Parameters.Add("chkProduceDealer", Data.OleDb.OleDbType.Boolean).Value
= chkProduceDealer.Checked
myCmd.Parameters.Add("txtOtherCustType", Data.OleDb.OleDbType.VarChar).Value
= txtOtherCustType.Text
myCmd.Parameters.Add("chkStandardBags", Data.OleDb.OleDbType.Boolean).Value
= chkStandardBags.Checked
myCmd.Parameters.Add("chkCustomBags", Data.OleDb.OleDbType.Boolean).Value =
chkCustomBags.Checked
myCmd.Parameters.Add("txtOtherBags", Data.OleDb.OleDbType.VarChar).Value =
txtOtherBags.Text
myCmd.ExecuteNonQuery()
myConn.Close()
.
- Follow-Ups:
- Re: Methodology
- From: Kevin Spencer
- Re: Methodology
- Prev by Date: Re: File/Project References within Solutions
- Next by Date: ReportViewer DataSource
- Previous by thread: Could Not Load MSVCM80
- Next by thread: Re: Methodology
- Index(es):
Relevant Pages
|