I have a form, with a DGV, textbox and a button. On the load event of the form: i have the following code.
this will bind the last record into textbox. Now i will press the button which has the following code:
this code shows only 1 record field in DataGridview. Why?
I have 4 records with same date&Time in DB, then why its showing only single record? Is my code Wrong? Please assist me.
Code:
dsSql2.Clear()
Dim selSale As String = "select top 1 Sale_Date from SaleInfo order by Sale_ID Desc"
Dim cmdSql As New SqlCommand(selSale, cnSql)
cmdSql.CommandType = CommandType.Text
daSql.SelectCommand = cmdSql
daSql.Fill(dsSql2, "SaleInfo")
TextBox1.DataBindings.Add("text", dsSql2, "SaleInfo.Sale_Date")
Code:
cnSql.Open()
Dim sel As String = "select * from SaleInfo where Sale_Date = '" & TextBox1.Text & "'"
Dim cmdSql As New SqlCommand(sel, cnSql)
cmdSql.CommandType = CommandType.Text
daSql.SelectCommand = cmdSql
daSql.Fill(dsSql2, "SaleInfo")
DataGridView1.DataSource = dsSql2
DataGridView1.DataMember = "SaleInfo"
cnSql.close
I have 4 records with same date&Time in DB, then why its showing only single record? Is my code Wrong? Please assist me.