Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid

Status
Not open for further replies.

teferi2002

Technical User
Sep 24, 2005
81
US
Can someone look at my code and tell me why i am getting no result from this page.




<%@ Page Trace="False" Debug="True" Language="VB" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<%@Import Namespace="System.Threading" %>





<script runat="server">

Sub Page_Load()

If Page.IsPostback Then

' user submitted page with customer ID
' create URL with query string for customer ID
' next page will not be a postback, so viewstate will be lost
Dim sRefreshURL As String = Request.Url.ToString() _
& "?custID=" & txtCustomer.Text

'& "&" & "custID1=" & txtCustomer1.Text

' use META REFRESH to start loading next page
mtaRefresh.Attributes.Add("http-equiv", "refresh")
mtaRefresh.Attributes.Add("content", "0;url=" & sRefreshURL)

' hide <form> section and show "wait" section
frmMain.Visible = False
divWait.Visible = True

Else

' get customer ID from query string
Dim sCustID As String = Request.QueryString("custID")

If sCustID > "" Then

' page is loading from META REFRESH element and
' so currently shows the "please wait" message
' a customer ID was provided so display results
divResult.Visible = True

' set URL for "Next Customer" hyperlink
lnkNext.NavigateUrl = Request.FilePath

' get data and bind to DataGrid in the page
FillDataGrid(sCustID)

Else

' either this is the first time the page has been
' loaded, or no customer ID was provided
' display controls to select customer
frmMain.Visible = True

End If
End If

End Sub

<%-------------------------------------------------------------%>



Sub FillDataGrid(sCustID As String)



Dim sConnect As String = "provider=MSDAORA;Data Source=xx;User ID=xx;Password=xx;"

'myConnection = new OleDbConnection(connectionString)
Dim oConnect As New OleDbConnection(sConnect)

oConnect.Open()



Dim sSelect As String = "SELECT DISTINCT V.VENDOR, R.ADDRNUM, V.VNAMEL, R.AADDR1, R.ACITY, R.ASTATE FROM VENDOR V,VENDADDR R,PLANHOLD P WHERE V.VENDOR = R.VENDOR AND P.VENDOR = R.VENDOR AND R.ASTATE LIKE '@CustomerID'"



' get DataReader for rows from Northwind Customers table

Dim oCommand As New OleDbCommand(sSelect, oConnect)
oCommand.Parameters.Add("@CustomerID", sCustID & "%" )

dgrResult.DataSource = oCommand.ExecuteReader()
dgrResult.DataBind()

lblResult.Text = "Results of your query for State '" _
& sCustID & "'"

' force current thread to sleep for 3 seconds
' to simulate complex code execution
Thread.Sleep(3000)

oConnect.Close()
End Sub

</script>

<!------------------------------------------------------------->
<!------------------------------------------------------------->

<html>
<head>

<!----- dynamically filled META REFRESH element ----->
<meta id="mtaRefresh" runat="server" />


<title>Displaying a "Please Wait" Message</title>
</head>
<body>
<span class="heading"><b>Displaying a "Please Wait" Message</B></span><hr />

<!----- form for selecting customer ----->
<form id="frmMain" Visible="False" runat="server">
Enter State ID:
<asp:Textbox id="txtCustomer" runat="server" />
<asp:Button id="btnSubmit" Text="Go" runat="server" />
</form>


<!----- "please wait" display ----->
<div id="divWait" Visible="False" runat="server">
<center>
<p>&nbsp;</p>
<p>&nbsp;</p>
<b>Searching, please wait...</b><p />
<p>&nbsp;</p>
<span id="spnError"></span>
<p>&nbsp;</p>
</center>
</div>


<!----- section for displaying results ----->

<div id="divResult" Visible="False" runat="server">
<b><asp:Label id="lblResult" runat="server" /></b><p />

<asp:DataGrid id="dgrResult" runat="server" autoGenerateColumns="false" cellpadding="4" width="100%">
<ItemStyle Font-Name="Arial" Font-Size="9pt" ForeColor="#000000"/>
<HeaderStyle Font-Name="Arial" Font-Size="9pt" Font-Bold="true" BackColor ="#003366" ForeColor ="#FFFFFF"/>
<AlternatingItemStyle Font-Name ="Arial" Font-Size ="9pt" BackColor ="#CCCCCC"/>


<columns>
<asp:boundColumn DataField="VENDOR" HeaderText="Vendor Number "/>
<asp:boundColumn DataField="ADDRNUM" HeaderText="Seq. No "/>
<asp:boundColumn DataField="VNAMEL" HeaderText="Vendor Name "/>
<asp:boundColumn DataField="AADDR1" HeaderText="Vendor Address "/>

</columns>
</asp:DataGrid></br></br></br></br>
<asp:Hyperlink id="lnkNext" Text="New Search" runat="server" />



</div>




<p />

<p>&nbsp;</p>

<span class="cite">
Testing to retrieve the right vendor list from Oracle data base.......
</span>

<hr />
</body>
</html>



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top