Hi I have a problem i hgaave a table in data grid view and i am updating data from data using a button. what i need to do is once the user update the data and click on update button i want to convert all string values to lower case. i am not using data table to populate my grid, is their any way that i can do that here is my code i am using to upgrade my grid
private void cmd_update_record_Click(object sender, EventArgs e)
{
if (dgRepair.RowCount == 0)
{
MessageBox.Show("No data available for update");
}
else
{
DataSet ChangedRepDataSet = new DataSet();
ChangedRepDataSet = ds_rep.GetChanges();
if (ChangedRepDataSet != null)
{
// Intializing object of Connectionclass to open connection
conn_obj = new ConnectionClass();
store_connection = conn_obj.connect();
// Sqlcommand object
SqlCommand cmdupdate;
cmdupdate = new SqlCommand();
cmdupdate.CommandType = CommandType.StoredProcedure;
cmdupdate.CommandText = "Update_Status_Grid";
//opening connection
cmdupdate.Connection = store_connection;
store_connection.Open();
//Adding Parameters for Repair table
cmdupdate.Parameters.Add("@OrgDescription", SqlDbType.VarChar, 100, "Description");
cmdupdate.Parameters["@OrgDescription"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@Description", SqlDbType.VarChar, 100, "Description");
cmdupdate.Parameters.Add("@OrgStatus", SqlDbType.VarChar, 15, "Status");
cmdupdate.Parameters["@OrgStatus"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@Status", SqlDbType.VarChar, 15, "Status");
cmdupdate.Parameters.Add("@OrgPartDes", SqlDbType.VarChar, 50, "PartDes");
cmdupdate.Parameters["@OrgPartDes"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@PartDes", SqlDbType.VarChar, 50, "PartDes");
cmdupdate.Parameters.Add("@OrgRepAction", SqlDbType.VarChar, 50, "RepAction");
cmdupdate.Parameters["@OrgRepAction"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@RepAction", SqlDbType.VarChar, 50, "RepAction");
cmdupdate.Parameters.Add("@OrgId", SqlDbType.BigInt ,1000, "Id");
cmdupdate.Parameters["@OrgId"].SourceVersion = DataRowVersion.Original;
//Adding the Parameters for invoice table
cmdupdate.Parameters.Add("@OrgRepCost", SqlDbType.Money, 1000, "RepCost");
cmdupdate.Parameters["@OrgRepCost"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@RepCost", SqlDbType.Money, 1000, "RepCost");
cmdupdate.Parameters.Add("@OrgPaymentPaid", SqlDbType.Money, 1000, "PaymentPaid");
cmdupdate.Parameters["@OrgPaymentPaid"].SourceVersion = DataRowVersion.Original;
cmdupdate.Parameters.Add("@PaymentPaid", SqlDbType.Money, 1000, "PaymentPaid");
da_rep.UpdateCommand = cmdupdate;
if (check == true)
{
try
{
da_rep.Update(ds_rep, "Repair");
ds_rep.AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show("Their is some problem in updating make sure you are entering right values " +
ex);
}
}
//}
//}
}
else
{
MessageBox.Show("no changes made");
}
//int modifiedRows = da_cus.Update(myChangedDataset);
//MessageBox.Show("Database has been updated successfully:" + no_of_rows_chang + " rows has been changed");
}
can any one help me
Thanks
Loading
Bechir BejaouiPosted Feb 27, 2009, 7:42 AM
You don't try to transform your data to lower case from the sql paramters so keep them normal, in the other hand you create a Trigger on the update action at the data base level
I give you an example of trigger
To create a trigger within Visual Studio take a look on this article
http://www.c-sharpcorner.com/UploadFile/pk_khuman/ManagedTrigersUsingCSharp02202007230729PM/ManagedTrigersUsingCSharp.aspx?ArticleID=fec8a799-1b2a-4429-9b4f-406ca3f0c019
always gullPosted Feb 26, 2009, 5:24 PM
cmdupdate.Parameters.Add("@Description".ToLower(new System.Globalization.CultureInfo("en-US")),SqlDbType.VarChar,25,"Description".ToLower(new System.Globalization.CultureInfo("en-US"))).ToString().ToLower(new System.Globalization.CultureInfo("en-Us"));
so i am trying Lower case with parameters with the column but seems to be not working for me.
is their any other way i can do it, or is their any way that i can convert stored procedure parameter value to lower case when i am using column name as source for the value.
Bechir BejaouiPosted Feb 26, 2009, 7:25 AM
string myContent = "sDsdsU";
myContent.ToLower(new System.Globalization.CultureInfo("en-US"));
The result will be
sdsdsu