Hi, 
I have a page that I am doing some thing on to get people to 
register for my site.  On that page they can enter certain 
information, and so far that is working semi ok.  The problem is 
that after it adds them to the database and I write a comand to 
query the database to return some expected values, I get nothing 
back.  I keep getting a -1 on the return value of the command.  I 
have checked the command and I can not find any errors with it nor 
can I figure out why it is not returning the values that I expect it 
to be giving me back.  I will include all of my C# code in the page 
as well as my asp.net code with the sql stored parameter I have.  
Please give me any help that you can so that I may resolve this 
issue.  Thanks.

C# code ::
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace ShadowMist
{
        public class WebForm1 : System.Web.UI.Page
        {
                protected System.Data.SqlClient.SqlCommand 
sqlSelectCommand1;
                protected System.Data.SqlClient.SqlCommand 
sqlInsertCommand1;
                protected System.Data.SqlClient.SqlCommand 
sqlUpdateCommand1;
                protected System.Data.SqlClient.SqlCommand 
sqlDeleteCommand1;
                protected System.Data.SqlClient.SqlConnection 
sqlConnection1;
                protected System.Web.UI.WebControls.DataGrid 
DataGrid1;
                protected System.Web.UI.WebControls.Button 
btnCreateChar;
                protected System.Web.UI.WebControls.DropDownList 
ddlGender;
                protected System.Web.UI.WebControls.Label lblGender;
                protected System.Web.UI.WebControls.DropDownList 
ddlRace;
                protected System.Web.UI.WebControls.Label lblRace;
                protected System.Web.UI.WebControls.TextBox txtEmail;
                protected System.Web.UI.WebControls.Label lblEmail;
                protected System.Web.UI.WebControls.TextBox 
txtVerifyPass;
                protected System.Web.UI.WebControls.Label 
lblVerifyPass;
                protected System.Web.UI.WebControls.TextBox 
txtNewPass;
                protected System.Web.UI.WebControls.Label 
lblNewCharPass;
                protected System.Web.UI.WebControls.TextBox 
txtNewCharName;
                protected System.Web.UI.WebControls.Label 
lblNewCharName;
                protected System.Web.UI.WebControls.Label 
lblRegister;
                protected System.Data.SqlClient.SqlDataAdapter 
sqlDataAdapter1;
        
                private void Page_Load(object sender, 
System.EventArgs e)
                {
                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection = sqlConnection1;
                        cmd.CommandType = 
CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter
("@CName", SqlDbType.VarChar, 50));
                        cmd.Parameters["@CName"].Value = 
txtNewCharName.Text;
                        cmd.CommandText = "spCheckIfCharExists";
                        sqlConnection1.Open();
                        lblRegister.Text = cmd.ExecuteNonQuery
().ToString();
                        sqlConnection1.Close();
                }

                #region Web Form Designer generated code
                override protected void OnInit(EventArgs e)
                {
                        //
                        // CODEGEN: This call is required by the 
ASP.NET Web Form Designer.
                        //
                        InitializeComponent();
                        base.OnInit(e);
                }

                private void InitializeComponent()
                {    
                        this.sqlSelectCommand1 = new 
System.Data.SqlClient.SqlCommand();
                        this.sqlInsertCommand1 = new 
System.Data.SqlClient.SqlCommand();
                        this.sqlUpdateCommand1 = new 
System.Data.SqlClient.SqlCommand();
                        this.sqlDeleteCommand1 = new 
System.Data.SqlClient.SqlCommand();
                        this.sqlConnection1 = new 
System.Data.SqlClient.SqlConnection();
                        this.sqlDataAdapter1 = new 
System.Data.SqlClient.SqlDataAdapter();
                        // 
                        // sqlSelectCommand1
                        // 
                        this.sqlSelectCommand1.CommandText = "SELECT 
CharName, CharPass, Email, Race, Gender FROM tblCharacter";
                        this.sqlSelectCommand1.Connection = 
this.sqlConnection1;
                        // 
                        // sqlInsertCommand1
                        // 
                        this.sqlInsertCommand1.CommandText = "INSERT 
INTO tblCharacter(CharName, CharPass, Email, Race, Gender) VALUES 
(@CharNa" +
                                "me, @CharPass, @Email, @Race, 
@Gender); SELECT CharName, CharPass, Email, Race, " +
                                "Gender FROM tblCharacter WHERE 
(CharName = @CharName)";
                        this.sqlInsertCommand1.Connection = 
this.sqlConnection1;
                        this.sqlInsertCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@CharName", 
System.Data.SqlDbType.VarChar, 50, "CharName"));
                        this.sqlInsertCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@CharPass", 
System.Data.SqlDbType.VarChar, 50, "CharPass"));
                        this.sqlInsertCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Email", 
System.Data.SqlDbType.VarChar, 100, "Email"));
                        this.sqlInsertCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Race", 
System.Data.SqlDbType.VarChar, 50, "Race"));
                        this.sqlInsertCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Gender", 
System.Data.SqlDbType.VarChar, 50, "Gender"));
                        // 
                        // sqlUpdateCommand1
                        // 
                        this.sqlUpdateCommand1.CommandText = 
@"UPDATE tblCharacter SET CharName = @CharName, CharPass = 
@CharPass, Email = @Email, Race = @Race, Gender = @Gender WHERE 
(CharName = @Original_CharName) AND (CharPass = @Original_CharPass) 
AND (Email = @Original_Email) AND (Gender = @Original_Gender) AND 
(Race = @Original_Race); SELECT CharName, CharPass, Email, Race, 
Gender FROM tblCharacter WHERE (CharName = @CharName)";
                        this.sqlUpdateCommand1.Connection = 
this.sqlConnection1;
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@CharName", 
System.Data.SqlDbType.VarChar, 50, "CharName"));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@CharPass", 
System.Data.SqlDbType.VarChar, 50, "CharPass"));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Email", 
System.Data.SqlDbType.VarChar, 100, "Email"));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Race", 
System.Data.SqlDbType.VarChar, 50, "Race"));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Gender", 
System.Data.SqlDbType.VarChar, 50, "Gender"));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_CharName", 
System.Data.SqlDbType.VarChar, 50, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "CharName", System.Data.DataRowVersion.Original, 
null));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_CharPass", 
System.Data.SqlDbType.VarChar, 50, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "CharPass", System.Data.DataRowVersion.Original, 
null));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_Email", 
System.Data.SqlDbType.VarChar, 100, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "Email", System.Data.DataRowVersion.Original, 
null));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_Gender", 
System.Data.SqlDbType.VarChar, 50, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "Gender", System.Data.DataRowVersion.Original, 
null));
                        this.sqlUpdateCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_Race", 
System.Data.SqlDbType.VarChar, 50, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "Race", System.Data.DataRowVersion.Original, 
null));
                        // 
                        // sqlDeleteCommand1
                        // 
                        this.sqlDeleteCommand1.CommandText = "DELETE 
FROM tblCharacter WHERE (CharName = @Original_CharName) AND 
(CharPass = @O" +
                                "riginal_CharPass) AND (Email = 
@Original_Email) AND (Gender = @Original_Gender) " +
                                "AND (Race = @Original_Race)";
                        this.sqlDeleteCommand1.Connection = 
this.sqlConnection1;
                        this.sqlDeleteCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_CharName", 
System.Data.SqlDbType.VarChar, 50, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "CharName", System.Data.DataRowVersion.Original, 
null));
                        this.sqlDeleteCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_CharPass", 
System.Data.SqlDbType.VarChar, 50, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "CharPass", System.Data.DataRowVersion.Original, 
null));
                        this.sqlDeleteCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_Email", 
System.Data.SqlDbType.VarChar, 100, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "Email", System.Data.DataRowVersion.Original, 
null));
                        this.sqlDeleteCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_Gender", 
System.Data.SqlDbType.VarChar, 50, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "Gender", System.Data.DataRowVersion.Original, 
null));
                        this.sqlDeleteCommand1.Parameters.Add(new 
System.Data.SqlClient.SqlParameter("@Original_Race", 
System.Data.SqlDbType.VarChar, 50, 
System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), 
((System.Byte)(0)), "Race", System.Data.DataRowVersion.Original, 
null));
                        // 
                        // sqlConnection1
                        // 
                        this.sqlConnection1.ConnectionString 
= "workstation id=HOME;packet size=4096;integrated 
security=SSPI;initial catalog=Sha" +
                                "dowMist;persist security 
info=False";
                        // 
                        // sqlDataAdapter1
                        // 
                        this.sqlDataAdapter1.DeleteCommand = 
this.sqlDeleteCommand1;
                        this.sqlDataAdapter1.InsertCommand = 
this.sqlInsertCommand1;
                        this.sqlDataAdapter1.SelectCommand = 
this.sqlSelectCommand1;
                        this.sqlDataAdapter1.TableMappings.AddRange
(new System.Data.Common.DataTableMapping[] {
                                                                
                                                                
                                                                
          new System.Data.Common.DataTableMapping
("Table", "tblCharacter", new System.Data.Common.DataColumnMapping[] 
{
                                                                
                                                                
                                                                
                                                                
                                                                
                                                                
                                          new 
System.Data.Common.DataColumnMapping("CharName", "CharName"),
                                                                
                                                                
                                                                
                                                                
                                                                
                                                                
                                          new 
System.Data.Common.DataColumnMapping("CharPass", "CharPass"),
                                                                
                                                                
                                                                
                                                                
                                                                
                                                                
                                          new 
System.Data.Common.DataColumnMapping("Email", "Email"),
                                                                
                                                                
                                                                
                                                                
                                                                
                                                                
                                          new 
System.Data.Common.DataColumnMapping("Race", "Race"),
                                                                
                                                                
                                                                
                                                                
                                                                
                                                                
                                          new 
System.Data.Common.DataColumnMapping("Gender", "Gender")})});
                        this.sqlDataAdapter1.UpdateCommand = 
this.sqlUpdateCommand1;
                        this.Load += new System.EventHandler
(this.Page_Load);

                }
                #endregion                              
        }
}

Asp.net ::
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" 
AutoEventWireup="false" Inherits="ShadowMist.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
        <HEAD>
                <title>WebForm1</title>
                <meta name="GENERATOR" Content="Microsoft Visual 
Studio .NET 7.1">
                <meta name="CODE_LANGUAGE" Content="C#">
                <meta name="vs_defaultClientScript" 
content="JavaScript">
                <meta name="vs_targetSchema" 
content="http://schemas.microsoft.com/intellisense/ie5";>
        </HEAD>
        <body MS_POSITIONING="GridLayout" bgColor="#666666">
                <FORM id="Form1" method="post" runat="server">
                        <P>
                                <asp:Label id="lblRegister" style="Z-
INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"
                                        Font-Size="Medium" 
Height="16px" Width="328px" Font-Bold="True">Please Register a new 
char here</asp:Label></P>
                        <P>
                                <asp:Label id="lblNewCharName" 
style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 64px"
                                        runat="server">Character 
Name:</asp:Label>
                                <asp:TextBox id="txtNewCharName" 
style="Z-INDEX: 104; LEFT: 128px; POSITION: absolute; TOP: 64px"
                                        runat="server"></asp:TextBox>
                                <asp:Label id="lblNewCharPass" 
style="Z-INDEX: 105; LEFT: 8px; POSITION: absolute; TOP: 128px"
                                
        runat="server">Password:</asp:Label>
                                <asp:TextBox id="txtNewPass" 
style="Z-INDEX: 106; LEFT: 128px; POSITION: absolute; TOP: 120px"
                                        runat="server" Width="156px" 
TextMode="Password"></asp:TextBox>
                                <asp:Label id="lblVerifyPass" 
style="Z-INDEX: 107; LEFT: 8px; POSITION: absolute; TOP: 184px"
                                        runat="server">Retype 
Password:</asp:Label>
                                <asp:TextBox id="txtVerifyPass" 
style="Z-INDEX: 108; LEFT: 128px; POSITION: absolute; TOP: 176px"
                                        runat="server" Width="156px" 
TextMode="Password"></asp:TextBox>
                                <asp:Label id="lblEmail" style="Z-
INDEX: 109; LEFT: 8px; POSITION: absolute; TOP: 240px" 
runat="server">Email Address:</asp:Label>
                                <asp:TextBox id="txtEmail" style="Z-
INDEX: 110; LEFT: 128px; POSITION: absolute; TOP: 232px"
                                        runat="server"></asp:TextBox>
                                <asp:Label id="lblRace" style="Z-
INDEX: 111; LEFT: 8px; POSITION: absolute; TOP: 296px" 
runat="server">Race:</asp:Label>
                                <asp:DropDownList id="ddlRace" 
style="Z-INDEX: 112; LEFT: 128px; POSITION: absolute; TOP: 288px" 
runat="server"
                                        Width="152px">
                                        <asp:ListItem 
Value="Human">Human</asp:ListItem>
                                        <asp:ListItem 
Value="Elf">Elf</asp:ListItem>
                                        <asp:ListItem 
Value="Dwarf">Dwarf</asp:ListItem>
                                        <asp:ListItem 
Value="Fairy">Fairy</asp:ListItem>
                                        <asp:ListItem 
Value="Gnome">Gnome</asp:ListItem>
                                        <asp:ListItem 
Value="Troll">Troll</asp:ListItem>
                                        <asp:ListItem 
Value="Orc">Orc</asp:ListItem>
                                </asp:DropDownList>
                                <asp:Label id="lblGender" style="Z-
INDEX: 113; LEFT: 8px; POSITION: absolute; TOP: 352px" 
runat="server">Gender</asp:Label>
                                <asp:DropDownList id="ddlGender" 
style="Z-INDEX: 114; LEFT: 128px; POSITION: absolute; TOP: 344px"
                                        runat="server" Width="152px">
                                        <asp:ListItem 
Value="Male">Male</asp:ListItem>
                                        <asp:ListItem 
Value="Female">Female</asp:ListItem>
                                        <asp:ListItem 
Value="Asexual">Asexual</asp:ListItem>
                                        <asp:ListItem Value="No 
Sex">No Sex</asp:ListItem>
                                </asp:DropDownList></P>
                        <P>
                                <asp:Button id="btnCreateChar" 
style="Z-INDEX: 115; LEFT: 72px; POSITION: absolute; TOP: 416px"
                                        runat="server" Text="Create 
Character"></asp:Button></P>
                        <P>
                                <asp:DataGrid id="DataGrid1" 
style="Z-INDEX: 101; LEFT: 464px; POSITION: absolute; TOP: 152px"
                                
        runat="server"></asp:DataGrid></P>
                </FORM>
        </body>
</HTML>





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to