I cant seem to solve the problem with my code:
public BindingSource getDataSource(string user_name)
{
string query = "Select user_name from UserPass_table where user_name Like @user_Name + '%' ;";
BindingSource bindSource = new BindingSource();
if (this.connect())
{
try
{
using (MySqlDataAdapter dA = new MySqlDataAdapter(query, connection))
{
using (DataTable DT = new DataTable())
{
dA.InsertCommand.Parameters.AddWithValue("@user_Name", user_name);
dA.Fill(DT);
bindSource.DataSource = DT;
}
}
}
catch (MySqlException e)
{
MessageBox.Show(e.Number.ToString());
bindSource.DataSource = null;
}
}
this.close();
return bindSource;
}
when I ran this code: it says System.NullReferenceException was unhandled at this line of code
dA.InsertCommand.Parameters.AddWithValue("@user_Name", user_name);