ms access - vb.net:Program can't save to database -


developing database software using vb.net program fails save database.

if microsoft.visualbasic.right(application.startuppath, 1) = "\"     sconnstring = "provider=microsoft.ace.oledb.12.0;data source=" & application.startuppath & "\database2.accdb" else     sconnstring = "provider=microsoft.ace.oledb.12.0;data source=" & application.startuppath & "\database2.accdb" end if  conn = new oledbconnection(sconnstring) conn.open() cmd.connection = conn cmd.commandtype = commandtype.text cmd.commandtext = "insert personaldata (title, full name,department,unit,phone no,email,gender,marital status,birthday,spouse birthday,wedding anniversary,educational qualification,no of kids,work experience) values (@title, @full name,@department,@unit,@phone no,@email,@gender,@marital status,@birthday,@spouse birthday,@wedding anniversary,@educational qualification,@no of kids,@work experience)" cmd.parameters.add("@title", oledbtype.varchar).value = textbox1.text cmd.parameters.add("@full name", oledbtype.varchar).value = textbox2.text cmd.parameters.add("@department", oledbtype.varchar).value = textbox3.text cmd.parameters.add("@unit", oledbtype.varchar).value = textbox4.text cmd.parameters.add("@phone no", oledbtype.varchar).value = textbox5.text cmd.parameters.add("@email", oledbtype.varchar).value = textbox6.text cmd.parameters.add("@gender", oledbtype.varchar).value = textbox7.text cmd.parameters.add("@marital status", oledbtype.varchar).value = textbox8.text cmd.parameters.add("@birthday", oledbtype.varchar).value = textbox9.text cmd.parameters.add("@spouse birthday", oledbtype.varchar).value = textbox10.text cmd.parameters.add("@wedding anniversary", oledbtype.varchar).value = textbox11.text cmd.parameters.add("@educational qualification", oledbtype.varchar).value = textbox12.text cmd.parameters.add("@no of kids", oledbtype.varchar).value = textbox13.text cmd.parameters.add("@work experience", oledbtype.varchar).value = textbox14.text cmd.executenonquery() msgbox("data uploaded successfully.", , " ") 

it shows syntax error point cmd.executenonquery same code works on software.

you must give error understand happen during executenonquery, looking code if not give error on connection maybe error inside variables.

i example if have string present special char ' need replace ''

example:

mystring = mystring.replace("'", "''")

idk if can you, without error message it's hard help.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -