TypeScript |
Connecting to a database with c#
Hi guys im doing a wee project at the minute i need to add a record to a database from a windows form on event button click (coded in c#) ive got code sorted that doesnt error however it doesnt save the records that i enter either i will post the code any help would be greatly appreciated

Kirtan PatelRank #292 · 8.6K reputationPosted Dec 1, 2009, 12:59 PM EST
Here is Your Modified Code ..I have Corrected Some Mistakes ..
private void confirmbut_Click(object sender, EventArgs e) { OleDbConnection Conn = new OleDbConnection ( "Provider=Microsoft.ACE.OLEDB.12.0; Data Source= H:\\VRUSLTD\\VRUS.accdb"); Conn.Open(); OleDbCommand Cmd = new OleDbCommand ("INSERT INTO Rental_Details(RentalID,Reg_No,CustID,StaffMember,PickUpDate,PickUpTime,Due_Back,DaysRental) SELECT '" + rentIDtb.Text + "','" + vehIDtb.Text + "','" + custIDtb + "','" + empIDtb + "','" + pickuptb + "','" + picktimetb + "','" + returntb + "','" + daystb + "'", Conn); Cmd.ExecuteNonQuery(); Conn.Close(); } if still having problem then feel free to ask me :)