Wrox Programmer Forums
|
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
 
Old May 23rd, 2007, 11:38 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default 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?

 
Old May 23rd, 2007, 12:56 PM
rlb rlb is offline
Authorized User
 
Join Date: Jan 2007
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 ).
 
Old May 24th, 2007, 07:21 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default

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?

 
Old May 24th, 2007, 07:32 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========
 
Old May 24th, 2007, 08:38 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default

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

 
Old May 24th, 2007, 08:52 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========
 
Old May 24th, 2007, 09:43 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default

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!

 
Old May 24th, 2007, 09:52 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========
 
Old May 24th, 2007, 10:13 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to scandalous Send a message via MSN to scandalous
Default

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?


 
Old May 24th, 2007, 10:25 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 "Using SQL Output Parameters..." burkecrosby BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 22 February 10th, 2010 05:33 PM
SQL Query output to XML using BCP HELP!! miamikk SQL Language 3 May 15th, 2009 08:22 AM
How to write T-SQL to retrieve the required Output anilkumar.dwivedi SQL Language 3 June 26th, 2008 12:37 AM
Categorizing SQL Output caterpillar SQL Server 2000 2 October 8th, 2006 04:52 PM
SQL output parameters ohiggs SQL Server 2000 4 February 9th, 2004 10:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.