 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 23rd, 2007, 11:38 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sql output
I have an output of a stored procedure thats declared as @message
depending on when it is used a different message should be seen.
-customer added
-already exists
-get help
the returned value for @message needs to come back
how would i accomplish this with a new pop up box?
|
|

May 23rd, 2007, 12:56 PM
|
|
Authorized User
|
|
Join Date: Jan 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
So you use your asp.net code to call the SQL stored pocedure, retrieve and store your @message as a variable( say String retrievedMessage).
Next you script the popup box and set the text of that popupbox to retrievedMessage.
You can use the javascript alert() box if you like (easy), or launch a new popup window (harder, see http://www.velocityreviews.com/forum...in-aspnet.html ).
|
|

May 24th, 2007, 07:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
So the best route to go is the Alert box?
sorry i am still new to this the link you gave me is for the easy way right?
|
|

May 24th, 2007, 07:32 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Spawning an alert box from inside an ASP.NET page is simple:
string sJavaScript;
string sMessage = "your message";
sJavaScript = "<script language='javascript'>";
sJavaScript += "alert('" + sMessage +"');";
sJavaScript += "</scr" + "ipt>";
Response.Write(sJavaScript);
hth.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|
|

May 24th, 2007, 08:38 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
GREAT!!
so how would I populate that box with my output from my stored procedure?
its declared as @message
(I know its very creative, but I am just learning)
I would imagine it would be a cmd.Parameter.IdontKnow
basically i am using VB and dont know how to get my OUTPUT
I have the Data entry down LOL
|
|

May 24th, 2007, 08:52 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Something like this:
cmd.Parameters.Add("@message", SqlDbType.VarChar, [length])
cmd.Parameters("@message").Direction = ParameterDirection.Output
then you would call
cmd.ExecuteNonQuery() (or whatever method you are using)
and then
Dim sMessage as String = Convert.ToString(cmd.Parameters("@message").Value)
hth.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|
|

May 24th, 2007, 09:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sorry, I think i am missing something like an Imports
I am getting an "end of statement expected" on
SqlDbType.VarChar, [200])
and on
ParamaterDirection.output
its telling me Name "ParameterDirection" not Declared?
how would i declare that?
Thanks again!
|
|

May 24th, 2007, 09:52 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
This code compiles fine as i just tested it:
cmd.Parameters.Add(New SqlParameter("@message", SqlDbType.VarChar, 200))
cmd.Parameters("@message").Direction = ParameterDirection.Output
My Imports are System.Data and System.Data.SqlClient (In the case of the latter, you will use the namespace that correlates to your database)
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|
|

May 24th, 2007, 10:13 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am very thankful!
just to clarify =)
i have this
Bunch of declarations
Dim Message As String = lblMessage
Using Conn As New SqlConnection ETC ETC
Conn.Open
Dim cmd As New SqlCommand ("AddCustomer", Conn)
Cmd.CommandType = Data.Comandtype.StoredProcedure
Bunch of parameters
cmd.Parameters.Add(New SqlParameter("@message", SqlDbType.VarChar, 200))
cmd.Parameters("@message").Direction = ParameterDirection.Output
cmd.ExecuteNonQUery()->what is this called so i can look it up and others like it
Dim sMessage As String = Convert.ToString (cmd.Parameters("@message",Value))
I am getting "Value is not a member of String on "@message.Value"
Thanks again
i just need to understand it then i wont ask again you know what i mean?
|
|

May 24th, 2007, 10:25 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Your code is wrong, it should be:
Dim sMessage as String = Convert.ToString(cmd.Parameters("@message").Value) (Value is a property, you are trying to supply it as a parameter)
ExecuteNonQuery is called just that, and is used to execute querys (UPDATE, DELETE, INSERT) that do not return a result set. By result set I mean you do not call a SELECT statement to return a bunch of data.
hth.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|
|
 |