473,508 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with stored procedure and parameters.

I'm trying to passing the Session["Locations"] value back to the store
procedure, but I'm having difficulty understanding stored procedures
and parameters. What I'm trying to accomplish is to have the Session
variable passed through as a parameter to the Stored Procedure where I
can test to see if any records exist? if no record exist then we can
move to the next page.

thanks,
protected void btnNext_Click(object sender, EventArgs e)
{

Session["Locations"] = Locations.Text;

Server.Transfer("AudioVisual.aspx");

/* Calling on Stored Procedure */
string connectionStr =
@"server=localhost;uid="";pwd="";trusted_connectio n=true;database=PMAEvents";
SqlConnection connectObj = new SqlConnection(connectionStr);
SqlCommand commandObj = new SqlCommand("eventtest",
connectionStr);
commandObj.CommandType.StoredProcedure;

commandObj.Parameters.Add(new
SqlParameter("@Locations",Session["Locations"]));

if( recordreturned == 0 )
{
Server.Transfer("nextpage.aspx");
}
else{
//Stay on the same page!!!!
}

Jan 8 '07 #1
2 1432
Hi,

You should read the docs, the code below most probably will not compile.
This line is wrong
commandObj.Parameters.Add(new
SqlParameter("@Locations",Session["Locations"]));

should read something like
commandObj.Parameters.Add(new SqlParameter("@Locations",
SqlDbType.VarChar)).Value = Session["Locations"];

--
Ignacio Machin
machin AT laceupsolutions com
<vn****@hotmail.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
I'm trying to passing the Session["Locations"] value back to the store
procedure, but I'm having difficulty understanding stored procedures
and parameters. What I'm trying to accomplish is to have the Session
variable passed through as a parameter to the Stored Procedure where I
can test to see if any records exist? if no record exist then we can
move to the next page.

thanks,
protected void btnNext_Click(object sender, EventArgs e)
{

Session["Locations"] = Locations.Text;

Server.Transfer("AudioVisual.aspx");

/* Calling on Stored Procedure */
string connectionStr =
@"server=localhost;uid="";pwd="";trusted_connectio n=true;database=PMAEvents";
SqlConnection connectObj = new SqlConnection(connectionStr);
SqlCommand commandObj = new SqlCommand("eventtest",
connectionStr);
commandObj.CommandType.StoredProcedure;

commandObj.Parameters.Add(new
SqlParameter("@Locations",Session["Locations"]));

if( recordreturned == 0 )
{
Server.Transfer("nextpage.aspx");
}
else{
//Stay on the same page!!!!
}

Jan 8 '07 #2
Thanks,

Where I'm a little lost (on the syntax) is how to test to see if any
records were returned. I wanted to test this inside of the

if( recordreturned == 0 )
{
Server.Transfer("nextpage.aspx");
}
else{
//Stay on the same page!!!!
}

thanks!

Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

You should read the docs, the code below most probably will not compile.
This line is wrong
commandObj.Parameters.Add(new
SqlParameter("@Locations",Session["Locations"]));

should read something like
commandObj.Parameters.Add(new SqlParameter("@Locations",
SqlDbType.VarChar)).Value = Session["Locations"];

--
Ignacio Machin
machin AT laceupsolutions com
<vn****@hotmail.comwrote in message
news:11**********************@q40g2000cwq.googlegr oups.com...
I'm trying to passing the Session["Locations"] value back to the store
procedure, but I'm having difficulty understanding stored procedures
and parameters. What I'm trying to accomplish is to have the Session
variable passed through as a parameter to the Stored Procedure where I
can test to see if any records exist? if no record exist then we can
move to the next page.

thanks,
protected void btnNext_Click(object sender, EventArgs e)
{

Session["Locations"] = Locations.Text;

Server.Transfer("AudioVisual.aspx");

/* Calling on Stored Procedure */
string connectionStr =
@"server=localhost;uid="";pwd="";trusted_connectio n=true;database=PMAEvents";
SqlConnection connectObj = new SqlConnection(connectionStr);
SqlCommand commandObj = new SqlCommand("eventtest",
connectionStr);
commandObj.CommandType.StoredProcedure;

commandObj.Parameters.Add(new
SqlParameter("@Locations",Session["Locations"]));

if( recordreturned == 0 )
{
Server.Transfer("nextpage.aspx");
}
else{
//Stay on the same page!!!!
}
Jan 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4693
by: berthelot samuel | last post by:
Hi everyone, I am currently trying to write a report based on a View of SQL Server. Basically, I have 3 tables : Hardware, SoftwareInstalled and Software with SoftwareInstalled that keeps track of...
0
6678
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
1
1296
by: Ken | last post by:
Hello, I have a webform that gets a record from SQL Server by using a stored procedure. The stored procedure uses 3 parameters in which after the record is found, stored procedure #2 runs to...
2
5437
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
4
1324
by: mattgcon | last post by:
When I use a stored procedure to insert data into a table and when the Datagrid refreshes two new columns are added. The dataSet is set up with one table with NO columns defined. Please help me on...
6
4961
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
7
9682
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
3
4078
by: Darth Ferret | last post by:
This thing is about to drive me crazy. I have about 50 queries in the AS400 that I need to put on a menu. Once I conquer this I have a bunch more rpg reports that I need to pass a date to. In the...
2
4080
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
5
8562
by: kaushal30 | last post by:
I am getting this error when I call a stored procedure from my C# code. It is a simple stored procedure with six params that inserts data : PROCEDURE LHD_SUR_ADMNEXP_HDR_INS ( ...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.