Imports System.Data.OleDb
Public Class Inquiry_Form
Dim provider As String
Dim dataFile As String
Dim connstring As String
Dim myConnection As OleDbConnection = New OleDbConnection
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
provider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
dataFile = "Database3.mdb"
connstring = provider & dataFile
myConnection.ConnectionString = connstring
myConnection.Open()
Dim str As String
str = "INSERT INTO Inquiry_Form([Date],[RefNo],[NameP],[Address],[Age],[PhoneNo],[MobileNo],[EmailAd],[ReferralQuestion],[Type_of_Unit],[Date_of_Purchase],[Purpose_of_Purchase],[Monthly_Income],[RName],[RAddress],[RMobileNo],[R2Name],[R2Address],[RMobileNo],[R2Name],[R2Address],[R2MobileNo],[AgentsName]) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
cmd.Parameters.Add(New OleDbParameter("Date", CType(TextBox1.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RefNo", CType(TextBox2.Text, String)))
cmd.Parameters.Add(New OleDbParameter("NameP", CType(TextBox3.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Address", CType(TextBox4.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Age", CType(TextBox5.Text, String)))
cmd.Parameters.Add(New OleDbParameter("PhoneNo", CType(TextBox6.Text, String)))
cmd.Parameters.Add(New OleDbParameter("MobileNo", CType(TextBox8.Text, String)))
cmd.Parameters.Add(New OleDbParameter("EmailAd", CType(TextBox7.Text, String)))
cmd.Parameters.Add(New OleDbParameter("ReferralQuestion", CType(ComboBox1.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Type_of_Unit", CType(ComboBox2.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Date_of_Purchase", CType(ComboBox3.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Purpose_of_Purchase", CType(ComboBox4.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Monthly_Income", CType(ComboBox5.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RName", CType(TextBox10.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RAddress", CType(TextBox11.Text, String)))
cmd.Parameters.Add(New OleDbParameter("RMobileNo", CType(TextBox15.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2Name", CType(TextBox12.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2Address", CType(TextBox13.Text, String)))
cmd.Parameters.Add(New OleDbParameter("R2MobileNo", CType(TextBox14.Text, String)))
cmd.Parameters.Add(New OleDbParameter("AgentsName", CType(TextBox16.Text, String)))
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
myConnection.Close()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox8.Clear()
TextBox7.Clear()
TextBox10.Clear()
TextBox11.Clear()
TextBox15.Clear()
TextBox12.Clear()
TextBox13.Clear()
TextBox14.Clear()
TextBox16.Clear()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
Menu_Page.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs)
Inquiry_FormBindingSource1.AddNew()
End Sub
Private Sub Inquiry_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database3DataSet.Inquiry_Form' table. You can move, or remove it, as needed.
Me.Inquiry_FormTableAdapter.Fill(Me.Database3DataSet.Inquiry_Form)
End Sub
End Class
|