integrating database to the window application

plumage

Active member
Joined
Jul 12, 2004
Messages
38
Programming Experience
Beginner
juz wanna check is this the correct way to integrate the database(access) to my vb.net. cos when i try it, it doesnt work.

and when i wanna view(eg.customer particular record) after pressing the view button, how can i do it..cos i try,but really cant work out..can i know wat code is required to view the records

can anyone please help me..thanks


is this the rite code to integrate the database.

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\assignment\My Documents\Assignmenttwo.mdb"


Dim MySQL As String = "INSERT INTO Customer(CustomerName,CustomerAddress,CustomerPostCode,CustomerGender,CustomerContactNo,CustomerDOB,CustomerIC) VALUES('" & txtName.Text & "','" & txtAddress.Text & "'," & txtPcode.Text & ",'" & cboGender.ValueMember & "','" & txtContactNo.Text & "','" & txtDOB.Text & "','" & txtIC.Text & "')"

Dim MyConn As New OleDbConnection(strConn)

Dim cmd As New OleDbCommand(MySQL, MyConn)

MyConn.Open()

 
try this

Dim strConn AsString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\assignment\My Documents\Assignmenttwo.mdb"


Dim MySQL AsString = "INSERT INTO Customer(CustomerName,CustomerAddress,CustomerPost Code,CustomerGender,CustomerContactNo,CustomerDOB, CustomerIC) VALUES('" & txtName.Text & "','" & txtAddress.Text & "'," & txtPcode.Text & ",'" & cboGender.ValueMember & "','" & txtContactNo.Text & "','" & txtDOB.Text & "','" & txtIC.Text & "')"

Dim MyConn AsNew OleDbConnection(strConn)

Dim cmd AsNew OleDbCommand(MySQL, MyConn)

MyConn.Open()
cmd.conncection.open()

cmd.ExecuteNonQuery()
cmd.Connection.close()
myconn.Close()
 
to view the record

Dim conn As New OleDb.OleDbConnection(strConnect)

dim SelectSQL as String

SelectSQL = "select * from customer"
Dim oAdaptor As New OleDb.OleDbDataAdapter(SelectSQL, conn)

Dim ds As New DataSet()

oAdaptor.Fill(ds)

conn.Close()

''''''' now you can navigate the Dataset
 

Similar threads

Back
Top