Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by PlausiblyDamp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...