R
Roy
Datagrid below. It will not display. The page shows nothing but the
html header. I have tested the query in query analyzer. Records exist
and should be displayed. I've stripped out all extraneous code to try
to narrow down where the syntactic flaw is but am still coming up
short. What am I missing here? I bet it's obvious... :-/
Option Strict On
imports Microsoft.VisualBasic
imports System
imports System.Data
imports System.Data.SqlClient
imports System.Web
imports System.Web.UI
imports System.Web.UI.WebControls
imports System.Web.UI.HtmlControls
Public Class Tier2Grid : Inherits System.Web.UI.Page
Protected DataGrid As System.Web.UI.WebControls.DataGrid
Dim MyConnection As SqlConnection
Dim gPoe As String
Dim gVoydoc As String
Public Sub Page_Load ( sender As Object, e As EventArgs )
IF (ISPOSTBACK = FALSE) THEN
BindData()
End If
End Sub
Public Sub BindData()
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
gPoe = Request.QueryString("poe")
gVoydoc = Request.QueryString("voydoc")
Dim SelectCmd As String = "SELECT TOP 500 IsNull(ocean_carrier_cd, '')
as 'Carrier'," _
& " IsNull(carrier_booking_nr, '') as 'Booking Num', IsNull(equipment,
'') as 'Equipment'," _
& " IsNull(Van_Owner, '') as 'Van Owner', IsNull(Tcon_Container_Num,'')
'Container Num', IsNull(Event_Code,'') as 'Event Code'," _
& " IsNull(Minof315_event_date,'') as 'Sail Date', IsNull(TCN,'') as
'TCN',IsNull(POD,'') as PoD," _
& " IsNull(Ship_Name,'') as 'Ship Name',IsNull(Pcfn,'') as
'PCFN',IsNull(LastEvent,'') as 'Last Event',IsNull(lasteventloc,'') as
'LE Location'," _
& " IsNull(LastEventdt,'') as 'LE Date',IsNull(Lastevent_shipname,'')
as 'LE Ship Name',IsNull(lastevent_scac,'') as 'LE SCAC'," _
& " IsNull(consigneecity,'') as 'Consignee City'" _
& " FROM firstvd WHERE voydoc = '"& gVoydoc & "' AND poe = '"& gPoe
&"'"
MyConnection = New
SqlConnection("server=localhost;uid=itv;pwd=itv_$ql!;database=maersk_test")
MyCommand = New SqlDataAdapter(SelectCmd, MyConnection)
DS = new DataSet()
MyCommand.Fill(DS)
DataGrid.DataSource = DS
DataGrid.DataBind()
Response.Write(SelectCmd)
End Sub
Sub DataGrid_EditCommand(Sender As Object, E As
DataGridCommandEventArgs)
DataGrid.EditItemIndex = CInt(E.Item.ItemIndex)
BindData()
End Sub
Sub DataGrid_CancelCommand(Sender As Object, E As
DataGridCommandEventArgs)
DataGrid.EditItemIndex = -1
BindData()
End Sub
Sub DataGrid_UpdateCommand(Sender As Object, E As
DataGridCommandEventArgs)
End Sub
End Class
html header. I have tested the query in query analyzer. Records exist
and should be displayed. I've stripped out all extraneous code to try
to narrow down where the syntactic flaw is but am still coming up
short. What am I missing here? I bet it's obvious... :-/
Option Strict On
imports Microsoft.VisualBasic
imports System
imports System.Data
imports System.Data.SqlClient
imports System.Web
imports System.Web.UI
imports System.Web.UI.WebControls
imports System.Web.UI.HtmlControls
Public Class Tier2Grid : Inherits System.Web.UI.Page
Protected DataGrid As System.Web.UI.WebControls.DataGrid
Dim MyConnection As SqlConnection
Dim gPoe As String
Dim gVoydoc As String
Public Sub Page_Load ( sender As Object, e As EventArgs )
IF (ISPOSTBACK = FALSE) THEN
BindData()
End If
End Sub
Public Sub BindData()
Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
gPoe = Request.QueryString("poe")
gVoydoc = Request.QueryString("voydoc")
Dim SelectCmd As String = "SELECT TOP 500 IsNull(ocean_carrier_cd, '')
as 'Carrier'," _
& " IsNull(carrier_booking_nr, '') as 'Booking Num', IsNull(equipment,
'') as 'Equipment'," _
& " IsNull(Van_Owner, '') as 'Van Owner', IsNull(Tcon_Container_Num,'')
'Container Num', IsNull(Event_Code,'') as 'Event Code'," _
& " IsNull(Minof315_event_date,'') as 'Sail Date', IsNull(TCN,'') as
'TCN',IsNull(POD,'') as PoD," _
& " IsNull(Ship_Name,'') as 'Ship Name',IsNull(Pcfn,'') as
'PCFN',IsNull(LastEvent,'') as 'Last Event',IsNull(lasteventloc,'') as
'LE Location'," _
& " IsNull(LastEventdt,'') as 'LE Date',IsNull(Lastevent_shipname,'')
as 'LE Ship Name',IsNull(lastevent_scac,'') as 'LE SCAC'," _
& " IsNull(consigneecity,'') as 'Consignee City'" _
& " FROM firstvd WHERE voydoc = '"& gVoydoc & "' AND poe = '"& gPoe
&"'"
MyConnection = New
SqlConnection("server=localhost;uid=itv;pwd=itv_$ql!;database=maersk_test")
MyCommand = New SqlDataAdapter(SelectCmd, MyConnection)
DS = new DataSet()
MyCommand.Fill(DS)
DataGrid.DataSource = DS
DataGrid.DataBind()
Response.Write(SelectCmd)
End Sub
Sub DataGrid_EditCommand(Sender As Object, E As
DataGridCommandEventArgs)
DataGrid.EditItemIndex = CInt(E.Item.ItemIndex)
BindData()
End Sub
Sub DataGrid_CancelCommand(Sender As Object, E As
DataGridCommandEventArgs)
DataGrid.EditItemIndex = -1
BindData()
End Sub
Sub DataGrid_UpdateCommand(Sender As Object, E As
DataGridCommandEventArgs)
End Sub
End Class