Hi VAer-4038,
You need to use OdbcCommand.ExecuteReader method instead of OdbcCommand.ExecuteNonQuery method.
The command executes this stored procedure when you call ExecuteReader, and then you can use OdbcDataReader.Read method to read through the data.
Here is my test code you can refer to.
string AssignedStr;
private void button1_Click(object sender, EventArgs e)
{
using (OdbcConnection Cn = new OdbcConnection(connectionString)) //Access database
{
Cn.Open();
OdbcCommand cmd = new OdbcCommand("SELECT TOP 1 * FROM TableReservedString", Cn);
OdbcDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
AssignedStr = reader[0].ToString(); // index 0 will retrieve your first colum in my table
// Console.WriteLine(AssignedStr);
}
string sqlDelete = "DELETE FROM TableReservedString WHERE FieldString ='" + AssignedStr + "'";
OdbcCommand cmdDelete = new OdbcCommand(sqlDelete, Cn);
cmdDelete.ExecuteNonQuery();
}
}
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.