I’m getting an error when trying to fill a data table with data from a MySQL query using the adapter.
VisualStudio it’s telling me the error, “Input String was not in a correct format,” is on the line with adapter.Fill(myDataTable); (The procedure is just a basic select statement that returns some rows with text, varchar, and datetime values.)
the method is called like this: GetDataTable("CALL SomeProc()");
public static DataTable GetDataTable(string query)
{
string ConnString = ConfigurationManager.ConnectionStrings["randomconnstr"].ConnectionString.ToString();
MySqlConnection conn = new MySqlConnection(ConnString);
MySqlDataAdapter adapter = new MySqlDataAdapter();
adapter.SelectCommand = new MySqlCommand(query, conn);
DataTable myDataTable = new DataTable();
conn.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
conn.Close();
}
return myDataTable;
}
Your missing a quotation mark, it doesn’t look like you have closed the string.
EDIT **
Try Adding this :-