PDA

View Full Version : sp and datarepeater problem



tvfoto
03-29-2007, 05:23 PM
Hi all,

I dont have any errors but I get nothing displayed back. Did I do something wrong here. Thanks.

bkg: I try to create a asp.net page when I can look up a serialnumber using my sql stored produre and list the columns out using repeater control.

................

<%@ Import Namespace="System.Web.UI.WebControls"%>
<%@ Import Namespace="System.Web.UI.WebControls.Repeater"%>
<%@ Import Namespace="System.Data.SQLclient"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Sub SerialLookup(ByVal s As Object, ByVal e As EventArgs)
If Not IsPostBack Then

Dim connSerial As SqlConnection
Dim myDataList As SqlDataReader
connSerial = New SqlConnection
("server=myDBName;UID=myusername;PWD=mypwd;Database=dbname")


Dim cmd As New SqlCommand("Exec sp_getSerial", connSerial)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@serialNumber", textSerial.Text)
connSerial.Open()
myDataList = cmd.ExecuteReader()
Repeater1.DataSource = myDataList
Repeater1.DataBind()
myDataList.Close()
connSerial.Close()

End If
End Sub


Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs)

End Sub
</script>


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>get serial</title>
<link href="report.css" rel="stylesheet" type="text/css"/>
</head>

<body>

<div>
<form id="form1" runat="server">
&nbsp;&nbsp;Serial:
<asp:TextBox Width="75px" ID='textSerial' runat="server" />&nbsp;&nbsp;
<asp:Button text='Serial' ID='Serial' onClick="SerialLookup" runat="server" />
</div>

<div>
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand" >


<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "t2name1")%>
<%#DataBinder.Eval(Container.DataItem, "t2name2")%>
<%#DataBinder.Eval(Container.DataItem,"t2name3")%>
</ItemTemplate>

</asp:Repeater>


</div>
</form>
</body>
</html>

tvfoto
03-29-2007, 07:53 PM
btw,

i already remove 'if not postback' which casue nothing to be displayed but another prob occurs. It keeps saying my SP can not be found and I know I have a good Sql connection (used in another page). Any thoughts?

tvfoto
03-29-2007, 09:30 PM
never mind, found the problem..since I have sp_getserial I dont have to use EXEC.