Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
ASP.NET: SQL INSERT (WTF?) and more...
Old 06-14-2007, 10:23 AM ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
Normally this is an easy task... I'm using VS 2005 (way cool, btw.)
The first thing I have an issue with is this:
Quote:
Error 1 'Public Event Click(sender As Object, e As System.Web.UI.ImageClickEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
In this version of VS, most coding is done in the html/source view and I'm trying to call the "ON CLICK" event.
Code:

<asp:ImageButtonID="ImageButton1"runat="server"onclick="ImageButton1.Click()"Style="z-index: 130; left: 465px;
position: absolute; top: 655px"ImageUrl="~/images/buttonSignUp.gif"/>
which is calling this bit of code:
Code:

PrivateSub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Try
'Declaration of all used variables
Dim SQLCommand AsNew Data.SqlClient.SqlCommand()
Dim SqlDataSource1 AsNew Data.SqlClient.SqlConnection("Data Source=SAMPLE;Initial Catalog=MMS;Persist Security Info=True;User ID=USER;Password=pas123")
'Parameters/values to be passed into SQL INSERT Command
SQLCommand.Parameters.Add("@One", SqlDbType.Char)
SQLCommand.Parameters(0).Value = txtFirst.Text
SQLCommand.Parameters.Add("@Two", SqlDbType.Char)
SQLCommand.Parameters(1).Value = txtLast.Text
SQLCommand.Parameters.Add("@Three", SqlDbType.Char)
SQLCommand.Parameters(2).Value = txtEmail.Text
SQLCommand.Parameters.Add("@Four", SqlDbType.Int)
SQLCommand.Parameters(3).Value = txtYear.Text
SQLCommand.Parameters.Add("@Five", SqlDbType.Char)
SQLCommand.Parameters(4).Value = rblGender.SelectedValue
SQLCommand.Parameters.Add("@Six", SqlDbType.Char)
SQLCommand.Parameters(5).Value = rblStudentType.SelectedValue
SQLCommand.Parameters.Add("@Seven", SqlDbType.Char)
SQLCommand.Parameters(6).Value = rblLiving.SelectedValue
SQLCommand.Parameters.Add("@Eight", SqlDbType.Int)
SQLCommand.Parameters(7).Value = dlInstitution.SelectedValue
SQLCommand.Parameters.Add("@Nine", SqlDbType.Char)
SQLCommand.Parameters(8).Value = rblReferredBy.SelectedValue
SQLCommand.Parameters.Add("@ten", SqlDbType.Char)
SQLCommand.Parameters(9).Value = txtOther.Text
'SQL Insert statement
SQLCommand.CommandText = "INSERT INTO StudentAssessment (FirstName, LastName, Email, BirthYear, Gender, StudentType, Housing, InstitutionID, ReferredByTypeID, RefByOtherDescription) VALUES & '(' & '@One' & '@Two' & '@Three' & '@Four' & '@Five' & '@Six' & '@Seven' & '@Eight' & '@Nine' & '@Ten' & ) "
SQLCommand.Connection = SqlDataSource1
SqlDataSource1.Open()
SQLCommand.ExecuteNonQuery()
SqlDataSource1.Close()
Catch ex As Exception
lblerr.Text = Err.Description()
EndTry
'Send user to Thanks page
Response.Redirect("ThankYou.aspx")
EndSub
Any thoughts on that?
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
 
Register now for full access!
Old 06-14-2007, 10:25 AM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
And secondly, I can't get Javascript to work with "OnMouseover" and "OnMouseOut"
Code:
<a onmouseover="javascript:this.src='images/buttonwhaton.gif'; return true;"onmouseout="javascript:this.src='images/buttonWhat.gif'; return true;"href="faq.aspx#what"><img src='images/buttonWhat.gif' alt="What"style="border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none"/></a>
Any thoughts on that one?
__________________
Need a vacation.

Last edited by mb2000inc; 06-14-2007 at 10:27 AM.. Reason: terrible copy and paste and webastertalk is inserted in my code
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-14-2007, 05:27 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
I don't know about your javascript, but it looks like you're trying to use java script in place of .NET coding. Your imageButton1 object variable doesn't have a method called Click, which explains why you can't call it.

onclick="ImageButton1.Click()"
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-15-2007, 10:42 AM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
Quote:
Originally Posted by Learning Newbie View Post
I don't know about your javascript, but it looks like you're trying to use java script in place of .NET coding. Your imageButton1 object variable doesn't have a method called Click, which explains why you can't call it.

onclick="ImageButton1.Click()"
Actually, you were looking at the second one... in the first one, I implemented the click method. And the second one is strictly an "href" event.
__________________
Need a vacation.

Last edited by mb2000inc; 06-15-2007 at 10:45 AM.. Reason: I can't type
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-15-2007, 12:58 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Huh???

There is no click method. You can override OnClick, call it directly, or respond to the event it throws after registering for notifications to that event. But an event can't be implemented. Interfaces are implemented, so if you created one you could call it IClickable and then write a class - say a web form - that implements its OnClick method.

ImageButton1_Click != ImageButton1.Click()
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-15-2007, 04:53 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
sorry, I missunderstood where you were coming from. In the starting post at the top if the page there is this:
Code:
<asp:ImageButtonID="ImageButton1"runat="server"onclick="ImageButton1.Click()"Style="z-index: 130; left: 465px;
position: absolute; top: 655px"ImageUrl="~/images/buttonSignUp.gif"/>
So there is an click method...i guess.... I'm sorry for being a pain. I'm just really trying to understand what's happening with with it.
(yes, I'm an amatuer...as if you couldn't tell )
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-15-2007, 04:56 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
This is the error I get when I do this:
Quote:
Server Error in '/WebProject' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC32022: 'Public Event Click(sender As Object, e As System.Web.UI.ImageClickEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

Source Error:

Line 107: top: 747px" Width="429px"></asp:Label>Line 108: Line 109: <asp:ImageButton ID="ImageButton1" runat="server" onclick="ImageButton1.Click()" Style="z-index: 120; left: 468px; position: absolute; top: 678px" ImageUrl="~/images/buttonSignUp.gif" />Line 110: Line 111: </form>
Source File: C:\WebProject\Default.aspx Line: 109
So, how do i fix it, and what is a "RaiseEvent"?
__________________
Need a vacation.

Last edited by mb2000inc; 06-15-2007 at 04:58 PM.. Reason: still can't type
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-15-2007, 05:09 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
There is no click method. There's a click event, but an event and a method are very different things. Ignore what it tells you about using RaiseEvent, because you want to respond to the event, not raise it. You want to be notified that something happened (in this case, a user clicked a button) instead of letting other code know that something happened.

In the designer, in design view, you should be able to double click the button, and Visual Studio is supposed to wire everything up for you. Try that, but if not, we'll go over the manual way, too.

You can create a method with the same calling signature (sender As Object, e As ImageClickEventArgs) and then attach the new method you create to the event itself.

In your VB code-behind, create a method called something like imageButton1_Click
(sender As Object, e As ImageClickEventArgs) and after the parameters, add Handles imageButton1.Click and/or set onclick to your new method that you just created in the html view. Because it gets run at the server, the compile will or at least should set up the plumbing behind the scenes for you.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-15-2007, 06:28 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
Ohhhhhhhhhhhhhhhhhhhhhhhhh!
I see! Lemme try that and I will get back to you. I won't be able to finish tonight, I will have to finish it tomorrow.

I will definitely give it a shot!
Thanks!

mb
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-15-2007, 07:23 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Yeah, no worries, but I probably won't be checking my email over the weekend.

Have you ever used C? A "delegate" in .net is like a function pointer. It describes a method you can call, and lets you do that in an anonymous, de-coupled way. The code in the ImageButton class under the covers uses a delegate aka a function pointer to call whatever method you wind up assigning to the event handler. That's beneath the sheets, though, at the level you can take control, what you need to know is a delegate ( which is how events work ) describes a method, but isn't one. You create a method that has the same signature, because that's how they talk, that's the API for responding to that event, and then you subscribe to notifications that the event has happened, and those notifications are relayed directly to your method, which saves you from writing code that says something like "If Message.ID = Messages.ImageButtonClickEvent Then DoThis()".

Now that we've cleared up some confusion, let's answer your question "So, how do i fix it, and what is a "RaiseEvent"?" because at this point it might help you (or someone else reading this) to understand events and how/when/why to respond to them, to understand how you would write code that raises an event.

The basic idea is you need to not break your code with all kinds of incestuous relationships where you have ten classes that can only work with all the other classes in your application, and aren't re-usable at all. Tightly coupled is bad. But you still might need to let other classes know something has happened, without knowing which classes you need to alert. The other option is usually you can write code to run a loop and keep asking a particular class if something happened, but that's really slow and bad code.

Class DirectoryWatcher
Dim Folder As String = "C:\Temp\"
Event FileAdded

Sub New()
Do
'Get a list of all the files in the directory, and then compare it to last time
If FileList.Count > oldFileCount Then RaiseEvent FileAdded
Loop
End Sub
End Class

Now that's oversimplified, and I haven't used VB.NET in a while, so I bet my syntax is off, in fact, I know it is. But that should give you the basic idea. It's not very efficient, and it would probably get run on a background thread, but it can tell other classes it doesn't know about when something happened - in this case, a file is added to a directory. Then other code in your application can get the notification so now it gets told when there's a change, and it can respond however it needs to.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-18-2007, 11:00 AM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
Yeah, I didn't realize it was Friday, when I posted....I'm kind of a dork that way.

So, I tried something else this morning (I tried putting it directly into the HTML)... just on a whim...It's not exactly working, but you can probably guess where I'm going with it. My only issue, now is syntax...

Call me "A.D.D."

Code:
<asp:ImageButtonID="ImageButton1"runat="server"Style="z-index: 120; left: 468px; position: absolute; top: 678px"ImageUrl="~/images/buttonSignUp.gif"/>
<% Dim SQLCommand AsNew Data.SqlClient.SqlCommand()
Dim first, last, email, other, gender, type, living, refby AsString
Dim year, inst AsInteger
Dim SqlDataSource1 AsNew Data.SqlClient.SqlConnection("Data Source=Sample;Initial Catalog=MMS;Persist Security Info=True;User ID=US123;Password=NAsample")
 
SqlDataSource1.Open()
 
'Parameters/values to be passed into SQL INSERT Command
first = Request.Form("txtFirst.Text")
last = Request.Form("txtlast.Text")
email = Request.Form("txtemail.Text")
year = Request.Form("txtyear.Text")
other = Request.Form("txtother.Text")
gender = Request.Form("rblgender.SelectedValue")
type = Request.Form("rblStudentType.SelectedValue")
living = Request.Form("rblLiving.SelectedValue")
refby = Request.Form("rblReferredBy.SelectedValue")
inst = Request.Form("dlInstitution.SelectedValue")
 
'SQL INSERT Command
SQLCommand.CommandText = "INSERT INTO SampleTable (FirstName, LastName, Email, BirthYear, Gender, StudentType, Housing, InstitutionID, ReferredByTypeID, RefByOtherDescription) VALUES"
SQLCommand.CommandText = SQLCommand.CommandText "'(' & 'first ' & "," & 'last' & "," & 'email' & "," & 'year' & "," & 'gender' & "," & 'type' & "," & 'living' & "," & 'inst' & "," & 'refby' & "," & 'other' & ')"
SQLCommand.Connection = SqlDataSource1
'This is where the error is comming from:
SQLCommand.ExecuteNonQuery()
'This part is fine
SqlDataSource1.Close()
 
Response.Redirect("ThankYou.aspx")
 
%>
I really do appreciate your knowledge, you are truly gifted.
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-18-2007, 01:15 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
What's wrong with the syntax? I'm not at the web dev machine, so I can't copy/paste it to see the error messages right now. I'm heading to a meeting soon, so if you want to paste the error(s) you're getting I'll be glad to take a look when I get back.

Here's a code change I would highly recommend.

Try
'SQL INSERT Command
SQLCommand.CommandText = "INSERT INTO SampleTable (FirstName, LastName, Email, BirthYear, Gender, StudentType, Housing, InstitutionID, ReferredByTypeID, RefByOtherDescription) VALUES"
SQLCommand.CommandText = SQLCommand.CommandText "'(' & 'first ' & "," & 'last' & "," & 'email' & "," & 'year' & "," & 'gender' & "," & 'type' & "," & 'living' & "," & 'inst' & "," & 'refby' & "," & 'other' & ')"
SQLCommand.Connection = SqlDataSource1
'This is where the error is comming from:
SQLCommand.ExecuteNonQuery()
'This part is fine
SqlDataSource1.Close()
Catch Ex As Exception
Response.Write("There was an error trying to run the query.<br />" + Ex.Message + "<br /><i>" + ex.StackTrace + "</i>")
Response.End
End Try

Without this extra code, your app will error out and give the user a nasty page they won't like,
if anyone enters a bad value in your form. Using a try block is like "On Error Goto X" in
VB 6 and lower. This will jump down to the "catch" block if an error is hit inside, and
continue running your code like it's okay.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-18-2007, 02:07 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
This is how it comes out.



In case you couldn't make out the small print, it said, "End Of Statment Expected". (if you want to see the full size image, you can do so here: http://i14.photobucket.com/albums/a3...l/errorlog.jpg)

What did I miss? Am I missing quotation marks, an apostrophe?, a parenthesis?

-stumped.
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-18-2007, 02:17 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
You have:

SQLCommand.CommandText = SQLCommand.CommandText "a string"

When it looks like you want

SQLCommand.CommandText = SQLCommand.CommandText & "a string"

Oh, and just so I don't steer you wrong, a lot of people will say including a stack trace in the message when you hit an exception is a security risk. I put that in there so you have more info to debug a problem with if one comes up, but give things some though.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-18-2007, 03:53 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
Quote:
Originally Posted by Learning Newbie View Post
You have:

SQLCommand.CommandText = SQLCommand.CommandText "a string"

When it looks like you want

SQLCommand.CommandText = SQLCommand.CommandText & "a string"

Oh, and just so I don't steer you wrong, a lot of people will say including a stack trace in the message when you hit an exception is a security risk. I put that in there so you have more info to debug a problem with if one comes up, but give things some though.
I just tried to add the "&" and it still tells me "End of statement expected."
What could I possibly be missing? I thought the syntax was fine...

And I have no problems with the stack trace.... it helps greatly to know what your errors are.
__________________
Need a vacation.

Last edited by mb2000inc; 06-18-2007 at 03:56 PM.. Reason: typing issues
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-18-2007, 06:26 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
Ok, so I was playing around with it and came up with this:
Code:
SQLCommand.CommandText = "INSERT INTO SampleTable (FirstName, LastName, Email, BirthYear, Gender, StudentType, Housing, InstitutionID, ReferredByTypeID, RefByOtherDescription) VALUES"
SQLCommand.CommandText = SQLCommand.CommandText & " '(' & 'first' & , & 'last' & , & 'email' & , & 'year' & , & 'gender' & , & 'type' & , & 'living' & , & 'inst' & , & 'refby' & , & 'other' & ')' "
Essentially, what you suggested.... and I got the first error to go away (yay):
Quote:
"End Of Statement Expected"
Then this popped up from the Try/Catch code you gave me (awesome suggestion, btw):
Quote:
Line 1: Incorrect syntax near '('.
at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQuer yTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ASP.default_aspx.__Renderform1(HtmlTextWriter __w, Control parameterContainer) in C:\SamplProject\Default.aspx:line 137
So, I guess the issue is still, "What is the correct Syntax?"

Honestly, you are the most helpful person, that I've come across in ANY forum (or website) that I've visited, and you seem to know your stuff. If I were hiring, you'd be a shoe in at 6 figures!
__________________
Need a vacation.

Last edited by mb2000inc; 06-18-2007 at 06:27 PM.. Reason: ...I still can't type XD!
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-20-2007, 01:16 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Thanks for the job offer! Maybe one day I'll take you up on that, although for now my wife would kick my @$$ if I even talked about leaving my current job.

Did you ever say what database you're using? I'm guessing it's either SQL Server, or MS Access, and I'm guessing SQL, but this brings up an important point. You can write queries that start with Select Max(SomeField), so max is a built-in function. You can't use it as a field name without wrapping it in brackets or quotes, like Select [Max], MoreFields or Select "Max" blah blah blah. If you're using Access, First and Last are aggregate functions, and not acceptable as field names without square brackets. I don't think that's what's going on, but your code sample:

Code:
SQLCommand.CommandText = "INSERT INTO SampleTable (FirstName, LastName, Email, BirthYear, Gender, StudentType, Housing, InstitutionID, ReferredByTypeID, RefByOtherDescription) VALUES"
SQLCommand.CommandText = SQLCommand.CommandText & " '(' & 'first' & , & 'last' & , & 'email' & , & 'year' & , & 'gender' & , & 'type' & , & 'living' & , & 'inst' & , & 'refby' & , & 'other' & ')' "
Reminds me of this point, and also I think wrapping your variables in ' marks tells SQL to treat them as literal strings. Instead, try:

Code:
SQLCommand.CommandText = "INSERT INTO SampleTable (FirstName, LastName, Email, BirthYear, Gender, StudentType, Housing, InstitutionID, ReferredByTypeID, RefByOtherDescription) VALUES"
SQLCommand.CommandText = SQLCommand.CommandText & " (" & "first" & "," & "last" & "," & "email" & "," & "year" & "," & "gender" & "," & "type" & "," & "living" & "," & "inst" & "," & "refby" & "," & "other" & ")"
Basically it's just VB strings vs SQL strings. We'll forget the exact syntax rules for now, and look at a debugging tip. Change line 137 from

SQLCommand.ExecuteNonQuery()

To

Response.Write("SQL: <b>" + SQLCommand.CommandText + "</b>")

Your code won't error out, but it won't actually do the work against the database, either. It'll just spit out the SQL it wants to execute to the page. Then you copy it into Query Analyzer, try to run it, and the error message they give you there is actually useful, it'll tell you a lot more than the ASP.NET error about it happened on line 137, which is ExecuteNonQuery. That, or the SQL will run just fine, and you narrow the bug down to web server code and not database related.

Try that out and see if it improves the situation. Next lesson is using stored procedures to make this a lot simpler.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-20-2007, 01:50 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
Thanks! I will give that a shot and get back to you.
(just wait... I have another thread to post for input, later on)

I'll give you a hint:


__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-20-2007, 05:38 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
DUDE!!! You are a coding GENIUS!
Thank You!!


Now about the other thing......
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 06-20-2007, 05:57 PM Re: ASP.NET: SQL INSERT (WTF?) and more...
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Yeah, but I wish I could be a different type of genius!

Shoot me a PM with a link to your other question after you post a thread. I'm guessing it's on captchas?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ASP.NET: SQL INSERT (WTF?) and more...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.66832 seconds with 12 queries