Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,821 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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);
}
}
Try this modification:
da_Customer = new SQLiteDataAdapter(cmd);