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=Micro soft.Jet.OLEDB. 4.0; Data
Source=" + Server.MapPath( "_database/DragonImporting .mdb")
Dim myConn As New Data.OleDb.OleD bConnection(con nectString)
myConn.Open()
Dim strSQL As String = "INSERT INTO tblContactForm1 (txtName, txtCompany,
txtPhone, txtEmail, txtComments, chkGrower, chkProduceDeale r,
txtOtherCustTyp e, chkStandardBags , chkCustomBags,t xtOtherBags) VALUES
(@txtName, @txtCompany, @txtPhone, @txtEmail, @txtComments, @chkGrower,
@chkProduceDeal er, @txtOtherCustTy pe, @chkStandardBag s, @chkCustomBags,
@txtOtherBags)"
Dim myCmd As New Data.OleDb.OleD bCommand(strSQL , myConn)
myCmd.Parameter s.Add("txtName" , Data.OleDb.OleD bType.VarChar). Value =
txtName.Text
myCmd.Parameter s.Add("txtCompa ny", Data.OleDb.OleD bType.VarChar). Value =
txtCompany.Text
myCmd.Parameter s.Add("txtPhone ", Data.OleDb.OleD bType.VarChar). Value =
txtPhone.Text
myCmd.Parameter s.Add("txtEmail ", Data.OleDb.OleD bType.VarChar). Value =
txtEmail.Text
myCmd.Parameter s.Add("txtComme nts", Data.OleDb.OleD bType.VarChar). Value =
txtComments.Tex t
myCmd.Parameter s.Add("chkGrowe r", Data.OleDb.OleD bType.Boolean). Value =
chkGrower.Check ed
myCmd.Parameter s.Add("chkProdu ceDealer", Data.OleDb.OleD bType.Boolean). Value
= chkProduceDeale r.Checked
myCmd.Parameter s.Add("txtOther CustType", Data.OleDb.OleD bType.VarChar). Value
= txtOtherCustTyp e.Text
myCmd.Parameter s.Add("chkStand ardBags", Data.OleDb.OleD bType.Boolean). Value
= chkStandardBags .Checked
myCmd.Parameter s.Add("chkCusto mBags", Data.OleDb.OleD bType.Boolean). Value =
chkCustomBags.C hecked
myCmd.Parameter s.Add("txtOther Bags", Data.OleDb.OleD bType.VarChar). Value =
txtOtherBags.Te xt
myCmd.ExecuteNo nQuery()
myConn.Close()
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=Micro soft.Jet.OLEDB. 4.0; Data
Source=" + Server.MapPath( "_database/DragonImporting .mdb")
Dim myConn As New Data.OleDb.OleD bConnection(con nectString)
myConn.Open()
Dim strSQL As String = "INSERT INTO tblContactForm1 (txtName, txtCompany,
txtPhone, txtEmail, txtComments, chkGrower, chkProduceDeale r,
txtOtherCustTyp e, chkStandardBags , chkCustomBags,t xtOtherBags) VALUES
(@txtName, @txtCompany, @txtPhone, @txtEmail, @txtComments, @chkGrower,
@chkProduceDeal er, @txtOtherCustTy pe, @chkStandardBag s, @chkCustomBags,
@txtOtherBags)"
Dim myCmd As New Data.OleDb.OleD bCommand(strSQL , myConn)
myCmd.Parameter s.Add("txtName" , Data.OleDb.OleD bType.VarChar). Value =
txtName.Text
myCmd.Parameter s.Add("txtCompa ny", Data.OleDb.OleD bType.VarChar). Value =
txtCompany.Text
myCmd.Parameter s.Add("txtPhone ", Data.OleDb.OleD bType.VarChar). Value =
txtPhone.Text
myCmd.Parameter s.Add("txtEmail ", Data.OleDb.OleD bType.VarChar). Value =
txtEmail.Text
myCmd.Parameter s.Add("txtComme nts", Data.OleDb.OleD bType.VarChar). Value =
txtComments.Tex t
myCmd.Parameter s.Add("chkGrowe r", Data.OleDb.OleD bType.Boolean). Value =
chkGrower.Check ed
myCmd.Parameter s.Add("chkProdu ceDealer", Data.OleDb.OleD bType.Boolean). Value
= chkProduceDeale r.Checked
myCmd.Parameter s.Add("txtOther CustType", Data.OleDb.OleD bType.VarChar). Value
= txtOtherCustTyp e.Text
myCmd.Parameter s.Add("chkStand ardBags", Data.OleDb.OleD bType.Boolean). Value
= chkStandardBags .Checked
myCmd.Parameter s.Add("chkCusto mBags", Data.OleDb.OleD bType.Boolean). Value =
chkCustomBags.C hecked
myCmd.Parameter s.Add("txtOther Bags", Data.OleDb.OleD bType.VarChar). Value =
txtOtherBags.Te xt
myCmd.ExecuteNo nQuery()
myConn.Close()
Comment