Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27207

VS 2005 What is wrong with this code

$
0
0
I have a form, with a DGV, textbox and a button. On the load event of the form: i have the following code.
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")

this will bind the last record into textbox. Now i will press the button which has the following code:

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

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.

Viewing all articles
Browse latest Browse all 27207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>