Hi,
When I compile I get "Newline in Constant" error in the below code.
command.CommandText = "UPDATE [Alert_ProbMgmt] ='" + ProblemTicket + "' [Remedy_Ticket_Num] ='" + ProblemDescription + "'[Problem_Desc]='" + RootCauseStatus + "' [Root_Cause_Status]='" + RootCauseGroup + "'[Assigned_Remedy_Group]='" + ProblemTeamResourceAssigned + "'[Assigned_Remedy_Resource]='" + RootCauseApplication + "'[NULL]='" + WorkAround + "'[Work_Around]='" + WorkAroundDeterminedon + "'[Work_Around_Dt]='" + Reproducible + "'[Reproducible_ind]='" + RootCauseDetails + "'[Root_Cause_Details]='" + VendorName + "'[Vendor_Name]='" + VendorTicket + "'[Vendor_Ticket_Num]='" + VendorResourceContact + "'[Vendor_Contact]='" + KnownError + "'[Known_Error]='" + '");
Loading
Sanjeeb LenkaPosted Sep 16, 2013, 4:39 AM
i checked your query you forgot to separate fields with comma so it will not execute. try this modified query.
command.CommandText = "UPDATE [Alert_ProbMgmt] SET [Remedy_Ticket_Num] ='" + ProblemTicket + "',[Problem_Desc]='" + ProblemDescription + "' ,[Root_Cause_Status]='" + RootCauseStatus + "',[Assigned_Remedy_Group]='" + RootCauseGroup + "',[Assigned_Remedy_Resource]='" + ProblemTeamResourceAssigned + "',[NULL]='" + RootCauseApplication + "',[Work_Around]='" + WorkAround + "',[Work_Around_Dt]='" + WorkAroundDeterminedon + "',[Reproducible_ind]='" + Reproducible + "',[Root_Cause_Details]='" + RootCauseDetails + "',[Vendor_Name]='" + VendorName + "',[Vendor_Ticket_Num]='" + VendorTicket + "',[Vendor_Contact]='" + VendorResourceContact + "',[Known_Error]='" + KnownError + "'";
Vignesh KumarPosted Sep 16, 2013, 5:31 AM
Jignesh TrivediPosted Sep 16, 2013, 4:07 AM
Is your command execute successfully?
In your update query there is no comma between two updated column...
command.CommandText = "UPDATE [Alert_ProbMgmt] SET [Remedy_Ticket_Num] ='" + ProblemTicket + "' , [Problem_Desc]='" + ProblemDescription + "', [Root_Cause_Status]='" + RootCauseStatus + "',[Assigned_Remedy_Group]='" + RootCauseGroup + "',[Assigned_Remedy_Resource]='" + ProblemTeamResourceAssigned + "',[Root_Cause_System]='" + RootCauseApplication + "',[Work_Around]='" + WorkAround + "',[Work_Around_Dt]='" + WorkAroundDeterminedon + "',[Reproducible_ind]='" + Reproducible + "',[Root_Cause_Details]='" + RootCauseDetails + "',[Vendor_Name]='" + VendorName + "',[Vendor_Ticket_Num]='" + VendorTicket + "',[Vendor_Contact]='" + VendorResourceContact + "',[KE_Ticket_Num]='" + KnownError + "'";
try above query
hope this will help you.
Vignesh KumarPosted Sep 16, 2013, 4:01 AM
public class ProblemRepository
{
public static bool UpdateProbValues(string ProblemTicket, string ProblemDescription, string RootCauseStatus, string RootCauseGroup, string ProblemTeamResourceAssigned, string RootCauseApplication, string WorkAround, string WorkAroundDeterminedon, string Reproducible, string RootCauseDetails, string VendorName, string VendorTicket, string VendorResourceContact, string KnownError)
{
string strcon = ConfigurationManager.ConnectionStrings[Constants.EARSdConnectionString].ConnectionString;
using (SqlConnection connection = new SqlConnection(strcon))
{
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = "UPDATE [Alert_ProbMgmt] SET [Remedy_Ticket_Num] ='" + ProblemTicket + "'[Problem_Desc]='" + ProblemDescription + "' [Root_Cause_Status]='" + RootCauseStatus + "'[Assigned_Remedy_Group]='" + RootCauseGroup + "'[Assigned_Remedy_Resource]='" + ProblemTeamResourceAssigned + "'[Root_Cause_System]='" + RootCauseApplication + "'[Work_Around]='" + WorkAround + "'[Work_Around_Dt]='" + WorkAroundDeterminedon + "'[Reproducible_ind]='" + Reproducible + "'[Root_Cause_Details]='" + RootCauseDetails + "'[Vendor_Name]='" + VendorName + "'[Vendor_Ticket_Num]='" + VendorTicket + "'[Vendor_Contact]='" + VendorResourceContact + "'[KE_Ticket_Num]='" + KnownError + "'";
connection.Open();
command.ExecuteNonQuery();
}
return true;
}
}