|
-
Jun 3rd, 2004, 01:10 PM
#1
Thread Starter
Fanatic Member
-
Jun 3rd, 2004, 01:41 PM
#2
Thread Starter
Fanatic Member
STACK TRACE
[NullReferenceException: Object reference not set to an instance of an object.]
TransouthPOP.addadmins.saveAdmin() +49
TransouthPOP.addadmins.btnAdminSubmit_Click(Object sender, EventArgs e) +7
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
SUBROUTINE
Private Sub saveAdmin()
Try
sqlconn.Open()
With sqlcomm
.CommandType = CommandType.StoredProcedure
.CommandText = "sp_AddAdmin"
.Connection = sqlconn
.Parameters.Add("@username", txtAdminUser.Text)
.Parameters.Add("@pw", txtAdminPass1.Text)
.Parameters.Add("@fullname", txtAdminName.Text)
.Parameters.Add("@email", txtAdminEmail.Text)
.ExecuteNonQuery()
End With
sqlconn.Close()
Finally
sqlconn = Nothing : sqlcomm = Nothing
End Try
End Sub
-
Jun 3rd, 2004, 02:10 PM
#3
Member
did you declare sqlcomm as a new command first?
Dim sqlcomm As New SqlClient.SqlCommand
-
Jun 3rd, 2004, 02:36 PM
#4
Thread Starter
Fanatic Member
Dude you are the man,
I had it like this:
dim sqlcomm as SqlClient.SqlCommand
I put NEW in it and it worked.
Like i said I'm a NOOB So whats the difference between putting new and not?
THANK YOU BY THE WAY!!!
-
Jun 3rd, 2004, 03:04 PM
#5
Frenzied Member
Using New creates the object. Not using it only tells the compiler to get ready for an object at some point, i.e. save some memory for it.
You should probably add a catch to your try block, that's the reason to use it - to catch an error and deal with it somehow.
-
Jun 3rd, 2004, 03:19 PM
#6
Thread Starter
Fanatic Member
Awsome,
now i noticed catches are used to put errors in the debugging console, correct? or am I way off?
I'm making a webform, and would have to use a little javascript to accomplish an alert window.
where would i catch these errors to when building a webform?
Thanks again!
<-- when will i ever use this?????
-
Jun 3rd, 2004, 03:53 PM
#7
Frenzied Member
I don't build webforms, but catches help with debugging, yes, but also allow you to deal with the error. If there's an error, you can run some different code, give the user the option to try again, etc.
-
Jun 3rd, 2004, 05:48 PM
#8
Thread Starter
Fanatic Member
Thanks guys!
Thats awsome!
Expect to see me around alot more
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|