I don't have image column in my table.....It appears that you have an image column in your grid but the data bound to it is not valid images. We can't really be more specific than that without knowing about the data and how it is bound to the grid.
//Create new instance
UserDAL dal = new UserDAL();
clsUser userDel = new clsUser();
Interfaces intl = new Interfaces();
private void frmSUsers_Load(object sender, EventArgs e)
{
dgvUsers.DataSource = dal.Select("users", dgvUsers);
panTextResearch.Size = new Size(1118, 51);
panAdvancedResearch.Visible = false;
}
///the dal.select method
public DataTable Select(string table, DataGridView dgv)
{
try
{
string sqlRequest = "SELECT id,gender as 'GENDER',first_name as 'FIRST NAME',last_name as 'LAST NAME',email as 'EMAIL',username as 'USERNAME' ,password,contact as 'PHONE',address,user_type as 'USER TYPE',added_date,added_by FROM tbl_" + table;
sqlCon = new SqlConnection(myConn);
///
Connect();
///
cmd = new SqlCommand(sqlRequest, sqlCon );
///
ds = new DataSet();
dta = new SqlDataAdapter(cmd);
///
dt = new DataTable();
dta.Fill(dt);
///dgv.DataSource = dt;
//Personnalize column name
DataTableMapping map = new DataTableMapping("tbl_"+table , "tbl"+table );
map.ColumnMappings.Add("id", "ID");
map.ColumnMappings.Add("user_type", "User Type");
map.ColumnMappings.Add("gender", "Gender");
map.ColumnMappings.Add("first_name", "First Name");
map.ColumnMappings.Add("last_name", "Last Name");
map.ColumnMappings.Add("username", "Username");
map.ColumnMappings.Add("email", "Email");
map.ColumnMappings.Add("contact", "Phone");
//Add mapping to table
dta .TableMappings.Add(map);
//hide some columns
// dgv.Columns["id"].Visible = false;
// this.dgvUsers.Columns["added_date"].Visible = false;
//this.dgvUsers.Columns["added_by"].Visible = false;
//this.dgvUsers.Columns["password"].Visible = false;
}
catch(Exception e1)
{
MessageBox.Show(e1.Message,"Error",MessageBoxButtons.OK,MessageBoxIcon.Information );
}
finally
{
Disconnect();
dta.Dispose();
}
return dt;
}
string sqlRequest = "SELECT id,gender as 'GENDER',first_name as 'FIRST NAME',last_name as 'LAST NAME',email as 'EMAIL',username as 'USERNAME' ,
password,contact as 'PHONE',address,user_type as 'USER TYPE',added_by FROM tbl_" + table;
here is my user table, I excluded the extraction of the added_date field whose type is in timestamp, and the result is error-free. why an error in the added_date field with the type timestamp?
I did A with B and got no error. So why is there an error with A on B?
timestamp is the synonym for the rowversion data type and is subject to the behavior of data type synonyms. In DDL statements, use rowversion instead of timestamp wherever possible. For more information, see Data Type Synonyms (Transact-SQL).
The Transact-SQL timestamp data type is different from the timestamp data type defined in the ISO standard.
Note
The timestamp syntax is deprecated. This feature is in maintenance mode and may be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
rowversion Is a data type that exposes automatically generated, unique binary numbers within a database. rowversion is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The rowversion data type is just an incrementing number and does not preserve a date or a time.
01-01-0001
through 31-12-9999
SqlDbType.DateTime2
for your date parameter. Bit more found here : datetime2 (Transact-SQL) - SQL Server