小编use*_*564的帖子

如何使用ado.net调用存储过程

private void button1_Click(object sender, EventArgs e)
{
    try
    {
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = "Data Source=*******;Initial Catalog=ChatApp;User ID=Chatapplication;Password=****";
        conn.Open();
        SqlCommand cmd = new SqlCommand();
        string chatroomidno = textBox1.Text;
        string chatroomname = textBox2.Text;
        //cmd.CommandText = "Select ChatRoomID=@ChatRoomID,ChatRoomName=@ChatRoomName from tblChatRoom";
        //cmd.Connection = conn;
        SqlDataAdapter adapt = new SqlDataAdapter("Chatroomapp",conn);
        adapt.SelectCommand.CommandType = CommandType.StoredProcedure;
        DataSet ds=new DataSet();
        DataTable dt = new DataTable();
        adapt.SelectCommand.Parameters.Add(new SqlParameter("@ChatRoomID", SqlDbType.VarChar, 100));
        adapt.SelectCommand.Parameters["@ChatRoomID"].Value = chatroomidno;
        adapt.SelectCommand.Parameters.Add(new SqlParameter("@ChatRoomName", SqlDbType.VarChar, 50));
        adapt.SelectCommand.Parameters["@ChatRoomName"].Value = chatroomname;
        adapt.Fill(ds, "tblChatRoom");
        if (dt.Rows.Count > 0)
        { …
Run Code Online (Sandbox Code Playgroud)

sql-server asp.net ado.net stored-procedures

6
推荐指数
1
解决办法
3万
查看次数

一个页面只能有一个服务器端的Form标签.

Masterpage.aspx

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">

    </asp:ContentPlaceHolder>
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'>     
     </script>
     <script src="Chrome.js" type="text/javascript"></script>
     </head>
     <body>
     <form id="Master" runat="server">
      <table style="width:987px; margin:auto; height: 86px;">
       <tr style="background-color:#FFFFFF">
         <td class="style2">
           <img src="images/logo.jpg" alt="" width="235" height="73" />&nbsp;
             </td>
             <td style="vertical-align:middle;"class="style1">
             <div style="float:right; width:153px; height: 22px;">
             &nbsp;<asp:TextBox ID="TextBox1" runat="server" Height="20px" 
                                            style="margin-left: 0px" Width="140px">   
              </asp:TextBox>
              </div>
              <a href="">Forget Password?</a> </span></span>
               </td>
               <td class="style33">
              <div style="float:right; width:157px; height: 20px; margin-right: 1px;">
            <asp:TextBox ID="TextBox2" runat="server" Height="20px"  
                                            style="margin-left: 0px; margin-top:  
                                            Width="147px"></asp:TextBox>
                                        </div>

              <a href="Registration.aspx">New User Registration</a> …
Run Code Online (Sandbox Code Playgroud)

forms asp.net master-pages

2
推荐指数
1
解决办法
2万
查看次数