asp.net c# oledbconnection InvalidOperationException -
error: unrecognised escape sequence.
code:
string connectionstring = "provider=microsoft.ace.oledb.12.0;data source=|datadirectory|\drivebuy.accdb"; oledbconnection con = new oledbconnection(connectionstring); if (fileupload1.hasfile) { string spath = mappath(fileupload1.filename); fileupload1.postedfile.saveas(spath); con.open(); string mysql; mysql = "insert cars(make,model,price,picture) values (?,?,?,?)"; oledbcommand cmd = new oledbcommand(mysql, con); cmd.parameters.addwithvalue("@p1", tbmake.text); cmd.parameters.addwithvalue("@p2", tbmodel.text); cmd.parameters.addwithvalue("@p3", convert.todecimal(tbprice.text)); cmd.parameters.addwithvalue("@p4", fileupload1.filename); cmd.executenonquery(); con.close(); } else { lblerror.text = "image not uploaded"; } any ideas? i'm trying input data access database. error appears on connection string, "\"
cheers
you're passing empty connection string
string connectionstring = ""; in order connect database need specify valid connection string. this site might helpful.
edit
data directory supposed directory of access db
// fix data source correct directory string connectionstring = "provider=microsoft.ace.oledb.12.0;data source=c:\\drivebuy.accdb"; edit2
sorry parameters in fact correct pointed in comments d stanley, thanks.
Comments
Post a Comment