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
How To use on button click
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
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
C#:
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);
}
}
C#:
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);
any one can help me to solve this
Thanks
Last edited by a moderator: