473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Stored Procedures not found

I just want to call a stored procedure while working with Visual c#
2005 Express Edition and SQL Server
Here is my PressButton method and the subsequent method:

//pick up the date from the user
DateTime = this.dateTimeDatum.Value;

string str = dt.ToShortDateString();

//execute the stored procedure - it gets DateTime as parameter
string commandText = "Exec DBName..ProcessProcedure_Step1 '" +
DateTime.Parse(str) + "'";

string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
My ProcessProcedure
int returnedRows = 0;
string result = "";
SqlCommand command = new SqlCommand();
command.Connection = this.connection;//Connection already instantiated
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
connection.Close();
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}

Immediately it commes to command.ExecuteNonQuery(), it jumps into the
catch exception area with the message - Stored Procedure not found...

Is there any tricks I am missing?

Thanks in advance

Nov 17 '05 #1
10 2463
SqlCommand command = new
SqlCommand("DBName..ProcessProcedure_Step1",this.c onnection);
try
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}
finally
{
if(command .Connection.State == ConnectionState.Open)
command .Connection.Close();
}
"Stropher" <hm***@gmx.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I just want to call a stored procedure while working with Visual c#
2005 Express Edition and SQL Server
Here is my PressButton method and the subsequent method:

//pick up the date from the user
DateTime = this.dateTimeDatum.Value;

string str = dt.ToShortDateString();

//execute the stored procedure - it gets DateTime as parameter
string commandText = "Exec DBName..ProcessProcedure_Step1 '" +
DateTime.Parse(str) + "'";

string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
My ProcessProcedure
int returnedRows = 0;
string result = "";
SqlCommand command = new SqlCommand();
command.Connection = this.connection;//Connection already instantiated
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
connection.Close();
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}

Immediately it commes to command.ExecuteNonQuery(), it jumps into the
catch exception area with the message - Stored Procedure not found...

Is there any tricks I am missing?

Thanks in advance

Nov 17 '05 #2
sorry no need to ref the db either in the command text

SqlCommand("ProcessProcedure_Step1",this.connectio n);
try
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}
finally
{
if(command .Connection.State == ConnectionState.Open)
command .Connection.Close();
}

"Ian Frawley" <ye**@yeah.com> wrote in message
news:Ot****************@TK2MSFTNGP14.phx.gbl...
SqlCommand command = new
SqlCommand("DBName..ProcessProcedure_Step1",this.c onnection);
try
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}
finally
{
if(command .Connection.State == ConnectionState.Open)
command .Connection.Close();
}
"Stropher" <hm***@gmx.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I just want to call a stored procedure while working with Visual c#
2005 Express Edition and SQL Server
Here is my PressButton method and the subsequent method:

//pick up the date from the user
DateTime = this.dateTimeDatum.Value;

string str = dt.ToShortDateString();

//execute the stored procedure - it gets DateTime as parameter
string commandText = "Exec DBName..ProcessProcedure_Step1 '" +
DateTime.Parse(str) + "'";

string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
My ProcessProcedure
int returnedRows = 0;
string result = "";
SqlCommand command = new SqlCommand();
command.Connection = this.connection;//Connection already instantiated
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
connection.Close();
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}

Immediately it commes to command.ExecuteNonQuery(), it jumps into the
catch exception area with the message - Stored Procedure not found...

Is there any tricks I am missing?

Thanks in advance


Nov 17 '05 #3
Gav
Include the date as a parameter:

command.Parameters.Add("@Parametername", DateTime.Parse(str));

"Ian Frawley" <ye**@yeah.com> wrote in message
news:OT**************@TK2MSFTNGP09.phx.gbl...
sorry no need to ref the db either in the command text

SqlCommand("ProcessProcedure_Step1",this.connectio n);
try
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}
finally
{
if(command .Connection.State == ConnectionState.Open)
command .Connection.Close();
}

"Ian Frawley" <ye**@yeah.com> wrote in message
news:Ot****************@TK2MSFTNGP14.phx.gbl...
SqlCommand command = new
SqlCommand("DBName..ProcessProcedure_Step1",this.c onnection);
try
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}
finally
{
if(command .Connection.State == ConnectionState.Open)
command .Connection.Close();
}
"Stropher" <hm***@gmx.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I just want to call a stored procedure while working with Visual c#
2005 Express Edition and SQL Server
Here is my PressButton method and the subsequent method:

//pick up the date from the user
DateTime = this.dateTimeDatum.Value;

string str = dt.ToShortDateString();

//execute the stored procedure - it gets DateTime as parameter
string commandText = "Exec DBName..ProcessProcedure_Step1 '" +
DateTime.Parse(str) + "'";

string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
My ProcessProcedure
int returnedRows = 0;
string result = "";
SqlCommand command = new SqlCommand();
command.Connection = this.connection;//Connection already instantiated
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
connection.Close();
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}

Immediately it commes to command.ExecuteNonQuery(), it jumps into the
catch exception area with the message - Stored Procedure not found...

Is there any tricks I am missing?

Thanks in advance



Nov 17 '05 #4
heh heh heh missed his parameter, I'll get me coat.

"Gav" wrote in message
Include the date as a parameter:

command.Parameters.Add("@Parametername", DateTime.Parse(str));

"Ian Frawley" wrote in message

sorry no need to ref the db either in the command text

SqlCommand("ProcessProcedure_Step1",this.connectio n);
try
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}
finally
{
if(command .Connection.State == ConnectionState.Open)
command .Connection.Close();
}

"Ian Frawley" <ye**@yeah.com> wrote in message
news:Ot****************@TK2MSFTNGP14.phx.gbl...
SqlCommand command = new
SqlCommand("DBName..ProcessProcedure_Step1",this.c onnection);
try
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}
finally
{
if(command .Connection.State == ConnectionState.Open)
command .Connection.Close();
}
"Stropher" <hm***@gmx.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I just want to call a stored procedure while working with Visual c#
2005 Express Edition and SQL Server
Here is my PressButton method and the subsequent method:

//pick up the date from the user
DateTime = this.dateTimeDatum.Value;

string str = dt.ToShortDateString();

//execute the stored procedure - it gets DateTime as parameter
string commandText = "Exec DBName..ProcessProcedure_Step1 '" +
DateTime.Parse(str) + "'";

string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
My ProcessProcedure
int returnedRows = 0;
string result = "";
SqlCommand command = new SqlCommand();
command.Connection = this.connection;//Connection already instantiated
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
connection.Close();
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}

Immediately it commes to command.ExecuteNonQuery(), it jumps into the
catch exception area with the message - Stored Procedure not found...

Is there any tricks I am missing?

Thanks in advance



Nov 17 '05 #5
Thanks for your answers, but where do I have to place this?

Does the fact of the program not locating my stored procedure has to do
with the code or...?

The contributions do not seem to bring me further...

Nov 17 '05 #6
"Stropher" wrote in message

Well because you are passing an active connection to the DB that contains
the stored procedure you only have to set the command text to be the actual
name of the stored procedure.

What you was doing was setting the command text to "EXEC server.db.sp
@param" which aint needed
Thanks for your answers, but where do I have to place this?

Does the fact of the program not locating my stored procedure has to do
with the code or...?

The contributions do not seem to bring me further...

Nov 17 '05 #7
Or sorry Gav and Ian, ...

with this line
command.Parameters.AddWithValue("@date", DateTime.Parse(commandText));
and that of Ian Frawley
it was able to run through....

thanks and best regards

Nov 17 '05 #8
fine, good to know (at first it did not appear logical to me b/c I was
asking myself how it knows that it has to execute the statement).
Thanks very much...

one other question is, can I call more than one stored procedures
within a particular connection?

e.g.
...
command.Connection.Open();
returnedRows = command.ExecuteNonQuery(); //stored procedure for
drops a table
command.CommandText = CommandText2; //it gets another statement or
command text
noOfRows = command.ExecuteNonQuery();//create another table
........
Is it from programming technique okay so?

Nov 17 '05 #9
Yes you can, your connection just allows you to interact with the database
much in the same way as an ftp connection allows you too issue ftp commands
to a remote source. You can call as many or as little stored procedures as
you like. But remember don't keep your connection open un-necessarily.

Regards

Ian

"Stropher" <hm***@gmx.net> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
fine, good to know (at first it did not appear logical to me b/c I was
asking myself how it knows that it has to execute the statement).
Thanks very much...

one other question is, can I call more than one stored procedures
within a particular connection?

e.g.
...
command.Connection.Open();
returnedRows = command.ExecuteNonQuery(); //stored procedure for
drops a table
command.CommandText = CommandText2; //it gets another statement or
command text
noOfRows = command.ExecuteNonQuery();//create another table
........
Is it from programming technique okay so?

Nov 17 '05 #10
Much thanks...

Best regards,

Stropher

Nov 17 '05 #11

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

Similar topics

6
by: dwilliams | last post by:
Our organization has implemented an ASP.net application with an n-tiered architecture, made up of a business/data layer that calls T-SQL Stored procedures. We are attempting to better manage the...
2
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the...
5
by: Raquel | last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it seems to run fine but returns NOTHING. I mean..as if nothing has happened..not resultset is returned. I am passing value...
3
by: mdaetwyler | last post by:
Hi all I am trying to call a DB/2 v8.2 stored procedure from Perl DBI and am getting an error message telling me, that the routine could not be found in the library path. SQL0444N Routine...
6
by: dwilliams | last post by:
Our organization has implemented an ASP.net application with an n-tiered architecture, made up of a business/data layer that calls T-SQL Stored procedures. We are attempting to better manage the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...

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.