DataTable dtt = new DataTable();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "load_order_sale_all";
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dtt);
dgvorderSale.DataSource = dtt;
DataMember
field on the data grid view, but they forget to name the DataTable
with that same name.Loaded
or Visible
event handrer (or constructor) that populates the data grid view into a helper method, and then just have your timer Tick
event handler also call that same helper method, everything should just work.O_S_View
? That is explicitly mentioned in the error message yet not at all in any of your posts.DataTable
and rebinding every time. At the very least, just bind one DataTable
at the outset and then clear and refill that. Even better would be to not clear it and update it with just new data from the database.What isO_S_View
? That is explicitly mentioned in the error message yet not at all in any of your posts.
You shouldn't really be creating a newDataTable
and rebinding every time. At the very least, just bind oneDataTable
at the outset and then clear and refill that. Even better would be to not clear it and update it with just new data from the database.
Can you show us the SQL for that sproc?
ALTER proc [dbo].[load_order_sale_all]
as
SELECT [id] as 'blabla'
,[orderdate] as 'blabla'
,[valueadd] as 'blabla'
,[total] as 'blabla'
,[paid] as 'blabla'
,[still] as 'blabla'
,[nameee] as 'blabla'
,[sales] as 'blabla'
,[typecustomer] as 'blabla'
,[finaldiscount] as 'blabla'
,phone as 'blabla'
,email as 'blabla'
FROM O_S_View