question

Rowlandsfc avatar image
0 Votes"
Rowlandsfc asked Viorel-1 answered

why am i getting insufficient parameters supplied to the command

i have a windows forms application and using sqlite to connect to a database, im trying to display the contents of a table in a datagridview, it works if i dont use parameters but if i set up parameters then i get the error message

 using (SQLiteCommand cmd = conn.CreateCommand())
             {
                 try
                 {
                     cmd.CommandText = @"SELECT * FROM customer WHERE lastname = @LastName";
    
                     cmd.Parameters.Add("LastName", DbType.String).Value = txt_name.Text;
    
    
                     da_Customer = new SQLiteDataAdapter(cmd.CommandText, conn);
                     dt_Customer = new DataTable();
                     da_Customer.Fill(dt_Customer);
                     dgv_customer.DataSource = dt_Customer;
    
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message);
                 }
    
    
             }
dotnet-csharpwindows-formsdotnet-sqlite
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Try this modification:

 da_Customer = new SQLiteDataAdapter(cmd);
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.