asp.net - OleDb Exception in c# “No value given for one or more required parameters.” while trying to Select Data from Access database -



asp.net - OleDb Exception in c# “No value given for one or more required parameters.” while trying to Select Data from Access database -

i have next code:

public datatable opencon(pal.property objpal) { string query = "select userid,firstname,usertype tbl_user_login username=@username , password=@password , status=1"; oledbcommand objcmd = new oledbcommand(); objcmd.commandtext = query; objcmd.connection = oldbcon; oldbcon.open(); objcmd.parameters.add("@username", oledbtype.varchar).value = objpal.username; objcmd.parameters.add("@password", oledbtype.varchar).value = objpal.password; datatable dt = new datatable(); oledbdataadapter adp = new oledbdataadapter(objcmd); adp.fill(dt); homecoming dt; }

here want fetch values table according condition, when run code shows next error:

even though passed right parameters value in @username , @password. how can resolve error? please help.

try this:

public datatable opencon(pal.property objpal) { string query = "select userid,firstname,usertype tbl_user_login username=? , password=? , status=1"; oledbcommand objcmd = new oledbcommand(); objcmd.commandtext = query; objcmd.connection = oldbcon; oldbcon.open(); objcmd.parameters.add("@username", oledbtype.varchar).value = objpal.username; objcmd.parameters.add("@password", oledbtype.varchar).value = objpal.password; datatable dt = new datatable(); oledbdataadapter adp = new oledbdataadapter(objcmd); adp.fill(dt); homecoming dt; }

c# asp.net ms-access

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -