Methodology



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()




.



Relevant Pages

  • Methodology
    ... Thanks to members of this fourm, I was able to get this method to work to ... Dim myConn As New Data.OleDb.OleDbConnection ... Dim myCmd As New Data.OleDb.OleDbCommand ...
    (microsoft.public.vstudio.general)
  • Nova Scotian Pocket PC User Group
    ... I was thinking of creating a fourm where Nova Scotian Pocket PC users could ... go to discuss their handhelds and get help from other members. ...
    (microsoft.public.pocketpc)