Results 1 to 3 of 3

Thread: sp and datarepeater problem

  1. #1
    Join Date
    Oct 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default sp and datarepeater problem

    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>

  2. #2
    Join Date
    Oct 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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?

  3. #3
    Join Date
    Oct 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    never mind, found the problem..since I have sp_getserial I dont have to use EXEC.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •