我使用 Visual Basic 2008 和 SQL Server 数据库。我想在数据库中写入信息库存,我想像在 php 中一样排名我使用表来对信息进行排名,在 vb 中执行此操作的方法是什么。此代码仅将最后信息写入表中tbl_cars
Dim da As SqlDataAdapter
Dim dt As DataTable
Dim sqlconn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\m7md\Documents\Visual Studio 2008\Projects\Cars\Cars\cars.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
dt = New DataTable
da = New SqlDataAdapter
Dim sql As String = ("select * from tbl_cars ")
da = New SqlDataAdapter(sql, sqlconn)
sqlconn.Open()
da.Fill(dt)
For Each drRow As DataRow In dt.Rows
Label6.Text= (drRow.Item("db_type").ToString)
Label7.Text = (drRow.Item("db_gender").ToString)
Label8.Text = (drRow.Item("db_color").ToString)
Label9.Text = (drRow.Item("db_price").ToString)
Next
End Sub