0

how to resolve error CS1009 occurred in connection string

hello there, I'm trying to execute the following code but an error CS1009 unrecognized escape sequence occurred during execution when try to save entered values. So can anyone tell me what I'm doing wrong. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MAK { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } SqlConnection con = new SqlConnection("Data Source=DESKTOP-M9HJ6E7\MAK;Initial Catalog=CRUD_SP_DB;User ID=sa;Password=mak"); private void button1_Click(object sender, EventArgs e) { con.Open(); String Status = ""; if(radioButton1.Checked==true) { Status = radioButton1.Text; } else { Status = radioButton2.Text; } SqlCommand com = new SqlCommand("exec dbo.SP_Product_Insert '"+textBox2.Text+ "','" + comboBox1.Text + "','" +Status +"','" + DateTime.Parse(dateTimePicker1.Text) + "'", con); com.ExecuteNonQuery(); MessageBox.Show("Successfully saved "); } } }

16th Oct 2021, 11:31 AM
AbdulMajed Khan
AbdulMajed Khan - avatar
0 Answers