I have the following code on my page
[code]
Imports System.Data.Sql Client
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.P age
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
TimeDateLabel.T ext = String.Format(" Today is {0:F}", DateTime.Now)
schedulenameBox .Focus()
End Sub
Protected Sub GetOncall()
Dim dt As New DataTable
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim connectionStrin g As String = "Initial Catalog=mdr;Dat a Source=xxxxx;ui d=xxxxx;passwor d=xxxxx"
Dim con As New SqlConnection(c onnectionString )
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "sp_getoncallre sults"
cmd.Parameters. AddWithValue("@ schedname", schedulenameBox .Text)
cmd.Parameters. AddWithValue("@ sincedate", sincedateBox.Te xt)
Try
da.SelectComman d = cmd
da.Fill(dt)
GridView1.DataS ource = dt
GridView1.DataB ind()
con.Dispose()
Catch ex As Exception
Response.Write( "Error:" & ex.Message)
End Try
End Sub
Protected Sub clearButton_Cli ck(ByVal sender As Object, ByVal e As System.EventArg s) Handles clearButton.Cli ck
schedulenameBox .Text = ""
sincedateBox.Te xt = ""
GridView1.DataS ource = Nothing
GridView1.DataB ind()
End Sub
End Class
[code]
and I can see that my values are passed to my variables when I debug the code but the results for my datatable show 0 rows. Can someone tell me what I may have done wrong?
Thank you
Doug
[code]
Imports System.Data.Sql Client
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.P age
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
TimeDateLabel.T ext = String.Format(" Today is {0:F}", DateTime.Now)
schedulenameBox .Focus()
End Sub
Protected Sub GetOncall()
Dim dt As New DataTable
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim connectionStrin g As String = "Initial Catalog=mdr;Dat a Source=xxxxx;ui d=xxxxx;passwor d=xxxxx"
Dim con As New SqlConnection(c onnectionString )
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "sp_getoncallre sults"
cmd.Parameters. AddWithValue("@ schedname", schedulenameBox .Text)
cmd.Parameters. AddWithValue("@ sincedate", sincedateBox.Te xt)
Try
da.SelectComman d = cmd
da.Fill(dt)
GridView1.DataS ource = dt
GridView1.DataB ind()
con.Dispose()
Catch ex As Exception
Response.Write( "Error:" & ex.Message)
End Try
End Sub
Protected Sub clearButton_Cli ck(ByVal sender As Object, ByVal e As System.EventArg s) Handles clearButton.Cli ck
schedulenameBox .Text = ""
sincedateBox.Te xt = ""
GridView1.DataS ource = Nothing
GridView1.DataB ind()
End Sub
End Class
[code]
and I can see that my values are passed to my variables when I debug the code but the results for my datatable show 0 rows. Can someone tell me what I may have done wrong?
Thank you
Doug
Comment