ASP.NET Edit Update sending to a SQL Money Field

Results 1 to 2 of 2

Thread: ASP.NET Edit Update sending to a SQL Money Field

  1. #1
    Join Date
    Dec 1969

    Default ASP.NET Edit Update sending to a SQL Money Field

    I have two fields within a SQL table that are setup as &#039;Money&#039; fields. I am trying to create a datagridupdate and I cannot seem to find which class to set the variables too. I have tried decimal and integer, but it always errors out indicating I need to convert. What is the proper class to set which I can push back into a money field on the database, or do I need to convert? See the question marks below.<BR><BR>Dim Proofer_Rate as ? = Ctype(e.Item.Cells(7).Controls(0),TextBox).Text <BR>Dim Typist_Rate as ? = Ctype(e.Item.Cells(8).Controls(0),TextBox).Text <BR><BR>I found out that I believe I have to convert. I have been searching through examples on other sites and in books and it looks like I can convert when I assign the variable or when I create my update string. I have tried both and neither work. Anyone have any ideas for this noob, I would be appreciated.<BR><BR>Here is my convert when assigning:<BR>Dim Proofer_Rate As New SQLParameter(Ctype(e.Item.Cells(7).Controls(0),Tex tBox).Text, SQLDbType.Money, 8)<BR>Dim Typist_Rate As New SQLParameter(Ctype(e.Item.Cells(8).Controls(0),Tex tBox).Text, SQLDbType.Money, 8)<BR><BR>Here is my convert within the update string:<BR>Dim UpdateSQL as String = "Update Employee_Information SET First_Name=&#039;" & First_Name & "&#039;, Last_Name=&#039;" & Last_Name & "&#039;, Email=&#039;" & Email & "&#039;, Proofer=&#039;" & Proofer & "&#039;, Typist=&#039;" & Typist & "&#039;, Proofer_Rate=&#039;CONVERT(money, Proofer_Rate)&#039;, Typist_Rate=&#039;CONVERT(money, Typist_Rate)&#039; WHERE USER_ID=&#039;" & USER_ID & "&#039;"<BR><BR>I know this is a simple answer, I just cannot find it. Thanks again for your time.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: ASP.NET Edit Update sending to a SQL Money Fie

    I would do it in a slightly different way:<BR><BR>TxtProoferRate = e.item.findcontrol("txtProoferRate") &#060;--Or whatever your textbox is called!!<BR>TxtTypistRate= e.item.findcontrol("txtTypistRate")<BR><BR>Do the above for each text box <BR><BR>Now your UPDATE Statement:<BR><BR>"Update Employee_Information SET First_Name=@First_Name,Last_Name=@Last_Name,Email= @Email,Proofer=@Proofer,Typist=@Typist,Proofer_Rat e=@Proofer_Rate,Typist_Rate=<BR>@Typist_Rate WHERE USER_ID=@USER_ID"<BR><BR>Then your command statement - I&#039;ve used CmdUpdate for your SQLCommand<BR><BR>CmdUpdate.parameters.add("@Proof er_Rate", = TxtProoferRate.text<BR>CmdUpdate.parameters.add("@ Typist_Rate", = TxtTypistRate.text<BR><BR>Do the above for each parameter - Then execute it<BR><BR>This is off the top of my head so post back if you have any probs - including the relevant code<BR><BR>Hope it helps <BR><BR>Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts