Problem about date...

  • Thread starter Thread starter budi_s_ch
  • Start date Start date
B

budi_s_ch

strSQL = "INSERT INTO TrCS VALUES (" & _
Val(TxtTrId.Text) & ",'" & _

DtpTrDate.Value.ToShortDateString & "','"
& _

TxtCallerName.Text & "','" & _
CboProblem.Text & "','" & _
CboCauses.Text & "','" & _
TxtSolution.Text & "','Solve')"

Hi... This statement is wrong, how to solve it ???
Any one help please?
 
budi_s_ch said:
strSQL = "INSERT INTO TrCS VALUES (" & _
Val(TxtTrId.Text) & ",'" & _

DtpTrDate.Value.ToShortDateString & "','"
& _

TxtCallerName.Text & "','" & _
CboProblem.Text & "','" & _
CboCauses.Text & "','" & _
TxtSolution.Text & "','Solve')"

Hi... This statement is wrong, how to solve it ???
Any one help please?

You shouldn't put the values into the SQL string directly. You leave
yourself open to quoting problems, SQL injection attacks, and the
formatting problem you're currently running into.

Instead, use parameters.

See http://www.pobox.com/~skeet/csharp/faq/#db.parameters for more
information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top