2 Replies - 1059 Views - Last Post: 19 August 2008 - 04:15 AM Rate Topic: -----

#1 kueh82  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 08-August 08

Update Command

Post icon  Posted 19 August 2008 - 03:14 AM

i hv an update command as below:-

Dim UpdateString As New SqlCommand("Update Material SET" & _
" nDesc = " & txtDesc.Text & _
" where ID = " & Trim(txtID.Text) & "", sConn)
UpdateString.ExecuteNonQuery()

i cant update this field if the text box contain characters but it can successfully update if text box content is numeric. actually what is the problems? :(

Is This A Good Question/Topic? 0
  • +

Replies To: Update Command

#2 dineeshd  Icon User is offline

  • member icon

Reputation: 38
  • View blog
  • Posts: 619
  • Joined: 30-June 08

Re: Update Command

Posted 19 August 2008 - 03:44 AM

Are you getting any error when the textbox value contains characters?
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5800
  • View blog
  • Posts: 12,636
  • Joined: 16-October 07

Re: Update Command

Posted 19 August 2008 - 04:15 AM

View Postkueh82, on 19 Aug, 2008 - 06:14 AM, said:

i cant update this field if the text box contain characters but it can successfully update if text box content is numeric. actually what is the problems? :(


Makes sense, actually. Your nDesc is a text type? You DB is probably being over nice to you by implicitly converting a numeric value to character for you. For character (e.g. varchar) fields, you need quotes around static values. e.g. nDesc='foo'.

Maybe try:
 Dim UpdateString As New SqlCommand("Update Material SET" & _
            " nDesc = '" & txtDesc.Text & "'" &  _
            " where ID = " & Trim(txtID.Text) & "", sConn)


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1