c# - Update multiple mysql columns using parametarized update command -
In my application, I want to update the multiple MySQL columns using the UPDATE command. I tried it with the following code, but I know that it is really unsafe because it is how a query with parameters to update SQL injection led to the attacks, but I do not know that multiple MySQL column to write I < / P>
This is my code:
string constring = string.Format ("datasource = '{0}'; port = '{1}'; database = '{2 } '; Username = Claimproof; password = xxxxxxxxxxxxxxxx; Connect timeout; 180; Mand timeout = 180 ", Srhwarplebl. Text, Porto. Text, Databesmanabl. Text); String query = '+ this.loannumbertextbox.Text.Trim () +', pool = '' + this.loanpooltextbox.Text.Trim () + '', disblid = '' + This "update claimloans loannumber = set". disbidtextbox.Text.Trim () + '', class = '' + this.categorytxtbox.Text.Trim () + '', subcacategory = '' + this.subcategorytxtbox.Text.Trim () + '', invoices = ' "+ this.invoicenumbertextbox.Text.Trim () + '', invoicedate = '' + this.invoicedatetextbox.Text.Trim () + '', docs = '' + this.docscombobox.Text.Trim () + '' , Where user name = '"+ this.usernamelable.Text.Trim () +"'; "; MySqlConnection conwaqDatabase = New MySqlConnection (constring); MySqlCommand cmdwaqDatabase = New MySqlCommand (query, conwaqDatabase); MySqlDataReader myreader; Try {conwaqDatabase.Open (); Myreader = cmdwaqDatabase.ExecuteReader (); While (myreader.Read ()) {} MessageBox.Show ("Credential informations are updated"); ConwaqDatabase.Close (); } Hold {}
You can use something like this. You add the place holders in the SQL command and then you run the ExecuteReader then add the parameter value later.
Comments
Post a Comment