unixnag Posted June 23, 2010 Posted June 23, 2010 (edited) Hi every one i made a database gateways to access multiple database with Oledb I have made Insert() Select() Delete() but there is some problem in Update I am giving my Update code and their method of using but i am not able to decide how user will give fields ant its value and type send foe updation public void UpdateData(string DatabaseProvider, string DatabaseName, string TableName,Dictionary<string ,string> DC,string Condition) { string kk = null; int i = 0; foreach (KeyValuePair<string, string> jj in DC) { kk = kk + jj.Key + "=" + jj.Value ; if (i == DC.Count- 1) continue; kk = kk + ","; i++; } string ss = "Use " + DatabaseName + " update " + TableName + " set " + kk + Condition ; if (ocon.State == ConnectionState.Closed) { ocon.Open(); } ocmd = new OleDbCommand(ss, ocon); try { int aa= ocmd.ExecuteNonQuery(); if (aa >0) { MessageBox.Show("Record Successfully Updated"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } How To use on button click ConnectionManager cm = new ConnectionManager("SQL"); Dictionary<string,string > DC = new Dictionary<string,string>(); DC.Add("Price", "290"); DC.Add("High", "80000"); string condition = " where Symbol = 'CXD'"; cm.UpdateData("SQL", "info", "TBuyOrder", DC, condition); but problem is that the dictionary i make it is string type if user input DateTime ,Double,or anyother type then How we Recognize in our function any one can help me to solve this Thanks Edited June 23, 2010 by PlausiblyDamp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.