0

This is my code :

string sqllaydl = @"BULK INSERT dbo.Infosp1 FROM '@laydl' WITH (FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')";

SqlCommand cmd = new SqlCommand(sqllaydl, con);

SqlParameter para = new SqlParameter();
para.ParameterName = "@laydl";
para.Value = txblink.Text;

cmd.Parameters.Add(para);

cmd.ExecuteNonQuery();

MessageBox.Show("Đã lấy DL", "Thông báo");
Hienthi();

The value of @laydl when I insert from form is

D:\test.txt

enter image description here

But when I used debug, the value has two backslashes \\.

D:\\test.txt

So, I couldn't have a link to insert data, help me!

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Your backslash is being escaped. You have to use @"txblink.Text"

Kevin Raffay
  • 842
  • 5
  • 18