Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# and Vfp7 Memo Field
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00621630
Message ID:
00622068
Views:
29
>"Object reference not set to an instance of an object. "
>
>Do you Have an Idea ?

First, try and update a regular character field. Your problem could be an idiosyncracy with the memo field.

Here is some code from an ASP.NET page that I use to update a SQL server table that has a Text field which is the equivalent of a VFP Memo field. You will have to use Oledb instead of SqlClient, of course. Oledb uses ? for the parameters instead of @parameter.
        Dim sPhrase, sDefinition
        sPhrase = txtPhrase.Text
        sDefinition = txtDefinition.Text
        Dim updateCmd As String = "UPDATE dbo.Lexicon SET lex_cphrase = @lex_cphrase, lex_cdefinition = @lex_cdefinition WHERE (lex_ipk = @lex_ipk) ;"

        Dim myCommand As SqlCommand = New SqlCommand(updateCmd, SqlConnection1)
        myCommand.Parameters.Add(New SqlParameter("@lex_ipk", SqlDbType.Int))
        myCommand.Parameters.Add(New SqlParameter("@lex_cphrase", SqlDbType.VarChar, 40))
        myCommand.Parameters.Add(New SqlParameter("@lex_cdefinition", SqlDbType.Text))

        myCommand.Parameters("@lex_ipk").Value = sipk
        myCommand.Parameters("@lex_cphrase").Value = sPhrase
        myCommand.Parameters("@lex_cdefinition").Value = sDefinition

        ' Connect to the database and update the information.
        myCommand.Connection.Open()
        ' Test  whether the data was updated and display the 
        ' appropriate message to the user.
        Try
            myCommand.ExecuteNonQuery()
            message.Text = "<b>Record Updated.</b><br>"
        Catch ex As SqlException
            If ex.Number = 2627 Then
                message.Text = "ERROR: A record already exists with the same primary key"
            Else
                message.Text = "ERROR: Could not update record," _
                   & " please ensure the fields are correctly filled out."
                message.Style("color") = "red"
            End If
        End Try

        ' Close the connection.
        myCommand.Connection.Close()
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform