Hi everyone, I'm new here and is in need of some help.
I'm trying to complete my project, however I'm stuck at writing the data from the sql into the vb.net/asp.net gridview.
Was never good at database to start with and I had never learnt how to query from VB.NET.
Answers are truly appreciated :)
Btw, I got this code to connect to the database from online thread and add on my own code into it.
msgbox : Object reference not set to an instance of an object
Dim con As SqlConnection = New SqlConnection("Data Source=BHI88QP0M1\SERVER2012;Integrated Security=True")
Dim query As String = "SELECT Job_Status FROM rep WHERE Job_Start_Date = '2013-12-02' AND Job_Start_Time = '07:00:02'"
Dim cmd As SqlCommand
Dim reader As SqlDataReader
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
With cmd
.Connection = con
.CommandText = query
End With
reader = cmd.ExecuteReader()
Do While reader.Read()
Dim a As Integer
For a = 1 To 31
If query = "Finished" Then 'query -> don't know how to call back
serverStat.Rows(0).Cells(a).BackColor = Drawing.Color.DarkBlue
Else
serverStat.Rows(0).Cells(a).BackColor = Drawing.Color.Red
End If
Next
Loop
reader.Close()
con.Dispose()
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try