V
Viktor Popov
Hi,
I have trouble with the following:
I have this Stored Procedure:
IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'prUPUSERINFO' AND type = 'P')
DROP PROCEDURE prUPUSERINFO
GO
CREATE PROCEDURE prUPUSERINFO
@USRNAME VARCHAR(20),
@NAME VARCHAR(64),
@CITY VARCHAR(20),
@PHONE VARCHAR(16),
@ADDR VARCHAR(74),
@EML VARCHAR(64)
AS
UPDATE BLEK.USERS
SET
RealName=@NAME,UserCity=@CITY,UserPhone=@PHONE,UserAddr=@ADDR,UserEmail=@EML
WHERE Username=@USRNAME
When I execute it everythings is fine.
I develop ASP.NET C# Application
and do the following in one of the forms:
private void InsertBtn_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter dada = new SqlDataAdapter("UPDATE BLEK.USERS SET
RealName=@NAME,UserCity=@CITY,UserPhone=@PHONE,UserAddr=@ADDR,UserEmail=@EML
WHERE Username=@USRNAME",conn);
dada.UpdateCommand.CommandType = CommandType.Text;
conn.Open();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@USRNAME",
SqlDbType.VarChar,20));
dada.UpdateCommand.Parameters["@USRNAME"].Value = Session["usrName"];
dada.UpdateCommand.Parameters.Add(new SqlParameter("@NAME",
SqlDbType.VarChar,64));
dada.UpdateCommand.Parameters["@NAME"].Value = NameTB.Text.Trim();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@CITY",
SqlDbType.VarChar,20));
dada.UpdateCommand.Parameters["@CITY"].Value = CityTB.Text.Trim();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@PHONE",
SqlDbType.VarChar,16));
dada.UpdateCommand.Parameters["@PHONE"].Value = PhoneTB.Text.Trim();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@ADDR",
SqlDbType.VarChar,74));
dada.UpdateCommand.Parameters["@ADDR"].Value = AddressTB.Text.Trim();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@EML",
SqlDbType.VarChar,64));
dada.UpdateCommand.Parameters["@EML"].Value = EmailTB.Text.Trim();
dada.UpdateCommand.ExecuteNonQuery();
conn.Close();
}
Could you tell me waths the problem here?
When I Push the Button Insert The following error appears:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 104: SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
Line 105: SqlDataAdapter dada = new SqlDataAdapter("UPDATE BLEK.USERS SET
RealName=@NAME,UserCity=@CITY,UserPhone=@PHONE,UserAddr=@ADDR,UserEmail=@EML
WHERE Username=@USRNAME",conn);
Line 106: dada.UpdateCommand.CommandType = CommandType.Text;
Line 107: conn.Open();
Line 108: dada.UpdateCommand.Parameters.Add(new SqlParameter("@USRNAME",
SqlDbType.VarChar,20));
Source File: c:\inetpub\wwwroot\estates\pdata.aspx.cs Line: 106
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Estates.pdata.InsertBtn_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\estates\pdata.aspx.cs:106
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
Thank you very much!
Viktor
I have trouble with the following:
I have this Stored Procedure:
IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'prUPUSERINFO' AND type = 'P')
DROP PROCEDURE prUPUSERINFO
GO
CREATE PROCEDURE prUPUSERINFO
@USRNAME VARCHAR(20),
@NAME VARCHAR(64),
@CITY VARCHAR(20),
@PHONE VARCHAR(16),
@ADDR VARCHAR(74),
@EML VARCHAR(64)
AS
UPDATE BLEK.USERS
SET
RealName=@NAME,UserCity=@CITY,UserPhone=@PHONE,UserAddr=@ADDR,UserEmail=@EML
WHERE Username=@USRNAME
When I execute it everythings is fine.
I develop ASP.NET C# Application
and do the following in one of the forms:
private void InsertBtn_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter dada = new SqlDataAdapter("UPDATE BLEK.USERS SET
RealName=@NAME,UserCity=@CITY,UserPhone=@PHONE,UserAddr=@ADDR,UserEmail=@EML
WHERE Username=@USRNAME",conn);
dada.UpdateCommand.CommandType = CommandType.Text;
conn.Open();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@USRNAME",
SqlDbType.VarChar,20));
dada.UpdateCommand.Parameters["@USRNAME"].Value = Session["usrName"];
dada.UpdateCommand.Parameters.Add(new SqlParameter("@NAME",
SqlDbType.VarChar,64));
dada.UpdateCommand.Parameters["@NAME"].Value = NameTB.Text.Trim();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@CITY",
SqlDbType.VarChar,20));
dada.UpdateCommand.Parameters["@CITY"].Value = CityTB.Text.Trim();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@PHONE",
SqlDbType.VarChar,16));
dada.UpdateCommand.Parameters["@PHONE"].Value = PhoneTB.Text.Trim();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@ADDR",
SqlDbType.VarChar,74));
dada.UpdateCommand.Parameters["@ADDR"].Value = AddressTB.Text.Trim();
dada.UpdateCommand.Parameters.Add(new SqlParameter("@EML",
SqlDbType.VarChar,64));
dada.UpdateCommand.Parameters["@EML"].Value = EmailTB.Text.Trim();
dada.UpdateCommand.ExecuteNonQuery();
conn.Close();
}
Could you tell me waths the problem here?
When I Push the Button Insert The following error appears:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 104: SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
Line 105: SqlDataAdapter dada = new SqlDataAdapter("UPDATE BLEK.USERS SET
RealName=@NAME,UserCity=@CITY,UserPhone=@PHONE,UserAddr=@ADDR,UserEmail=@EML
WHERE Username=@USRNAME",conn);
Line 106: dada.UpdateCommand.CommandType = CommandType.Text;
Line 107: conn.Open();
Line 108: dada.UpdateCommand.Parameters.Add(new SqlParameter("@USRNAME",
SqlDbType.VarChar,20));
Source File: c:\inetpub\wwwroot\estates\pdata.aspx.cs Line: 106
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Estates.pdata.InsertBtn_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\estates\pdata.aspx.cs:106
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
Thank you very much!
Viktor