How to save data to mysql database using vb.net -
hey me find error @ code :) i'm new vb.net friends
try /*'con.open()*/ query = "insert mcs.custormer values(custormer_id,first_name,last_name,nic_no,c_address1,c_address2,c_address3,c_telephoneno,membership_date,business_name,g_name,g_nicno,g_address1,g_address2,g_address3,g_telephoneno)" & _ "values (@custormer_id,@first_name,@last_name,@nic_no,@c_address1,@c_address2,@c_address3,@c_telephoneno,@membership_date,@business_name,@g_name,@g_nicno,@g_address1,@g_address2,@g_address3,@g_telephoneno)" using cmd = new mysqlcommand(query, con) cmd.parameters.addwithvalue("@custormer_id", convert.toint32(txtcustormerid.text)) cmd.parameters.addwithvalue("@first_name", convert.tostring(txtfirstname.text)) cmd.parameters.addwithvalue("@last_name", convert.tostring(txtlastname.text)) cmd.parameters.addwithvalue("@nic_no", convert.tostring(txtnicno.text)) cmd.parameters.addwithvalue("@c_address1", convert.tostring(txtcaddress1.text)) cmd.parameters.addwithvalue("@c_address2", convert.tostring(txtcaddress2.text)) cmd.parameters.addwithvalue("@c_address3", convert.tostring(txtcaddress3.text)) cmd.parameters.addwithvalue("@c_telephoneno", convert.tostring(txtctelephoneno.text)) cmd.parameters.addwithvalue("@membership_date", convert.todatetime(dtpmembrshipdate.text)) cmd.parameters.addwithvalue("@business_name", convert.tostring(txtbusinessname.text)) cmd.parameters.addwithvalue("@g_name", convert.tostring(txtgname.text)) cmd.parameters.addwithvalue("@g_nicno", convert.tostring(txtgnicno.text)) cmd.parameters.addwithvalue("@g_address1", convert.tostring(txtgaddress1.text)) cmd.parameters.addwithvalue("@g_address2", convert.tostring(txtgaddress2.text)) cmd.parameters.addwithvalue("@g_address3", convert.tostring(txtgaddress3.text)) cmd.parameters.addwithvalue("@g_telephoneno", convert.tostring(txtgtelephoneno.text)) cmd.executenonquery() messagebox.show("new custormer added sucsessfully !") txtcustormerid.clear() txtfirstname.clear() txtlastname.clear() txtnicno.clear() txtcaddress1.clear() txtcaddress2.clear() txtcaddress3.clear() txtctelephoneno.clear() txtbusinessname.clear() txtgname.clear() txtgaddress1.clear() txtgaddress2.clear() txtgaddress3.clear() txtgtelephoneno.clear() txtgnicno.clear() end using catch ex exception msgbox(ex.message) 'da.dispose() 'ds.clear() ' dr.close() cmd.dispose() con.close() end try
when click save button error,
i try more , more, can't go forward. please me guys :)
try with
query = "insert mcs.custormer (custormer_id,first_name,last_name,nic_no,c_address1,c_address2,c_address3,c_telephoneno,membership_date,business_name,g_name,g_nicno,g_address1,g_address2,g_address3,g_telephoneno)" & _ "values (@custormer_id,@first_name,@last_name,@nic_no,@c_address1,@c_address2,@c_address3,@c_telephoneno,@membership_date,@business_name,@g_name,@g_nicno,@g_address1,@g_address2,@g_address3,@g_telephoneno)"
also please refer mysql insert syntax.hope helps.
Comments
Post a Comment