Quantcast
Channel: SQL Server Compact Forum
Viewing all articles
Browse latest Browse all 193

Cancel retrieve value when trying to get a singel column from a specific row using 'select .... where ...=@key

$
0
0

Hi:

I'm trying to retrieve a totals column from a table and having problems.  The table exists and contains a single row with 12 columns each containing a value.  when I execute the following code, I get 'no data exists for row/column.  I'm stupid so I can't see where I am getting wrong.  Can you PLEASE help?

       Dim key_value As String = Nothing

        Dim con As New SqlCeConnection("Data Source=" + sqlcedb)
        con.Open()
        Try
            cmd = New SqlCeCommand("Select rt_total from register_drawer where rt_id=@id", con)
            cmd.Parameters.AddWithValue("@id", selected_date)
            rdr = cmd.ExecuteReader
            rdr.Read()
            rdr.Close()
            key_value = rdr.Item(12)
            MsgBox(key_value)
            Txt_olddrawer.Text = rdr.GetString(12) '("rt_total")
        Catch ex As Exception
            register_drawer_read_err = register_drawer_read_err + ex.Message
            MsgBox(register_drawer_read_err, , msgtitle)
            MsgBox(key_value)
        End Try
        'rdr.Close()
        con.Close()


Viewing all articles
Browse latest Browse all 193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>