database - C# connection with MS access is not working? -
when start debugging , add together clients, can add together them, update them , read them. newly added clients won't save in database. i've checked if i'm using right file location , am:
public class dbaccess { private static string connectionstr; static dbaccess() { string mdffile; mdffile = @"c:\users\rik\documents\visual studio 2010\projects\week-2-opdracht\database\clienten.accdb"; connectionstr = @"provider=microsoft.ace.oledb.12.0;data source=" + mdffile + ";"; } public static dataset getwaardenquery(string sqlstr) { dataset ds = new dataset(); console.writeline(sqlstr); oledbconnection con = new oledbconnection(connectionstr); oledbdataadapter dap = new oledbdataadapter(sqlstr, con); dap.fill(ds); homecoming ds; } public static int uitvoerenquery(string sqlstr) { int resultaat = -1; console.writeline(sqlstr); oledbconnection con = new oledbconnection(connectionstr); oledbcommand cmd = new oledbcommand(sqlstr, con); seek { con.open(); resultaat = cmd.executenonquery(); } grab (exception exp) { string x = exp.message; } { if (con.state == connectionstate.open) { con.close(); } } homecoming resultaat; } } }
at first check connection string right or not making manual connection. help follow given link http://www.c-sharpcorner.com/uploadfile/b8d90a/connect-oledb-database-in-c-sharp-in-easy-steps/
c# database windows
No comments:
Post a Comment