this is my sql query with access:
Dim SQLstr2 As String = "Select count(*) as total, oDate from Order_Details where oNo = " + Request("oNo") + " group by oDate"
However, problem is, I am clueless about how to access the data that is derived from my count(*).
I tried this: Response.Write(reader2("total"))
All I get is that No data exists for the row/column.
I tried not to select oDate and even took away the WHERE, but the same problem persists. Any ideas please?here's a template code that might help you.
Dim ConnectionString As String = "Your_Connection_String"
Dim CommandText As String = "select Col1, Col2, Col3 from TableName"
Dim myConnection As New System.Data.SqlClient.SqlConnection(ConnectionString)
Dim myCommand As New System.Data.SqlClient.SqlCommand(CommandText, myConnection)
myConnection.Open()Dim DataReader As System.Data.SqlClient.SqlDataReader = myCommand.ExecuteReader()
If DataReader.HasRows Then
Do While DataReader.Read()
Response.Write(DataReader.Item("Col1"))
Response.Write(DataReader.Item("Col2"))
Response.Write("<BR>")
Loop
End If
DataReader.Close()
myconnection.close()
hth
No comments:
Post a Comment