Avatar of OliShim
OliShim

asked on 

GridView update not working in mySQL via ASP.NET 2.0

Hello,
I am trying to update a mySQL database via ASP.NET 2.0.  The update never saves the new values.  I am using an ENUM('True','False') datatype in the mySQL table for the rejectflag variable.  Any help would be appreciated!!!

Here is my code:

'script
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="cEvaluateSRBLL" SelectMethod="SelectSR"
     UpdateMethod="UpdateSR" OldValuesParameterFormatString="original_{0}">
                   <UpdateParameters>
                    <asp:Parameter Type="string" Direction="Input" Name="rejectflag" />
                    <asp:Parameter Type="string" Direction="Input" Name="newcomments" />
                    <asp:Parameter Type="Int32" Name="original_sid" />
                    <asp:ProfileParameter Type="Int32" PropertyName="UID" Name="original_uid" />
                   </UpdateParameters>                
                   <SelectParameters>
                   <asp:ProfileParameter Name="uid" PropertyName="UID" Type="Int32" />
                   </SelectParameters>
    </asp:ObjectDataSource>

.....
'vb object
   Public Function UpdateSR(ByVal rejectflag As String, ByVal newcomments As String, _
                     ByVal original_sid As Integer, ByVal original_uid As Integer) As Boolean

        Dim myComm As OdbcCommand = New OdbcCommand()
        Dim myConn As OdbcConnection = New OdbcConnection()

        myConn.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ToString()
        myConn.Open()
        myComm.Connection = myConn
        myComm.CommandType = Data.CommandType.Text
        myComm.CommandText = "UPDATE approval SET flag = 'O', rejectflag = '" & rejectflag & "', comments = '" & newcomments & "' WHERE sid = " & original_sid & " AND uid = " & original_uid

        myComm.ExecuteNonQuery()

        'clean up
        myConn.Close()
        myConn = Nothing
        myComm = Nothing
        GC.Collect()

        Return True
    End Function
Editors IDEsMicrosoft DevelopmentMySQL Server

Avatar of undefined
Last Comment
OliShim
ASKER CERTIFIED SOLUTION
Avatar of mankowitz
mankowitz
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of OliShim
OliShim

ASKER

Hello,
I forgot the DataKeysNames property in the Gridview!  Duh!  Thanks anyway mankowitz!
MySQL Server
MySQL Server

MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.

49K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo