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(stri ng DatabaseProvide r, string DatabaseName, string TableName,Dicti onary<string ,string> DC,string Condition)
{
string kk = null;
int i = 0;
foreach (KeyValuePair<s tring, 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.ExecuteNon Query();
if (aa >0)
{
MessageBox.Show ("Record Successfully Updated");
}
}
catch (Exception ex)
{
MessageBox.Show (ex.Message);
}
}
How To use on button click
ConnectionManag er cm = new ConnectionManag er("SQL");
Dictionary<stri ng,string > DC = new Dictionary<stri ng,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
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(stri ng DatabaseProvide r, string DatabaseName, string TableName,Dicti onary<string ,string> DC,string Condition)
{
string kk = null;
int i = 0;
foreach (KeyValuePair<s tring, 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.ExecuteNon Query();
if (aa >0)
{
MessageBox.Show ("Record Successfully Updated");
}
}
catch (Exception ex)
{
MessageBox.Show (ex.Message);
}
}
How To use on button click
ConnectionManag er cm = new ConnectionManag er("SQL");
Dictionary<stri ng,string > DC = new Dictionary<stri ng,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