未找到存储过程 [英] Stored Procedures not found
问题描述
我只想在使用Visual c时调用存储过程#
2005 Express Edition和SQL Server
这是我的PressButton方法和后续方法:
//从用户那里拿起日期
DateTime = this.dateTimeDatum.Value;
string str = dt.ToShortDateString();
//执行存储过程 - 它获取DateTime作为参数
string commandText =" Exec DBName..ProcessProcedure_Step1'' " +
DateTime.Parse(str)+"''" ;;
string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
我的ProcessProcedure
int returnedRows = 0;
string result ="" ;;
SqlCommand command = new SqlCommand();
command.Connection = this.connection; //已经实例化的连接
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;
}
立即命令命令.ExecuteNonQuery(),它跳转到
catch异常带消息的区域 - 未找到存储过程...
我缺少什么技巧吗?
提前致谢
SqlCommand command = new
SqlCommand(" DBName..ProcessProcedure_Step1",this.c onnection);
尝试
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result ="执行成功......" ;;
}
catch(SqlException ex)
{
result =" SQLException: + ex.Message;
}
最后
{
if(command .Connection.State == ConnectionState 。打开)
命令.Connection.Close();
}
" Stropher" < HM *** @ gmx.net>在消息中写道
news:11 ********************** @ g47g2000cwa.googlegr oups.com ...我只想在使用Visual c#
2005 Express Edition和SQL Server时调用存储过程
这是我的PressButton方法和后续方法:
/ /从用户那里拿起日期
DateTime = this.dateTimeDatum.Value;
string str = dt.ToShortDateString();
//执行存储procedure - 它将DateTime作为参数
string commandText =" Exec DBName..ProcessProcedure_Step1''" +
DateTime.Parse(str)+"''" ;;
string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
我的ProcessProcedure
int returnedRows = 0;
string result ="" ;;
SqlCommand command = new SqlCommand();
command.Connection = this .connection; //连接已经实例化
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result ="执行成功..." ;;
connection.Close( );
}
catch(SqlException ex)
{
result =" SQLException: + ex.Message;
}
立即命令command.ExecuteNonQuery(),它跳转到
catch异常区域,显示消息 - 找不到存储过程...
我缺少什么技巧?
提前致谢
抱歉没必要在命令文本中引用数据库
SqlCommand(" ProcessProcedure_Step1",this.connectio n);
尝试
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result ="执行成功..." ;;
}
catch(SqlException ex)
{
result =" SQLException: + ex.Message;
}
最后
{
if(command .Connection.State == ConnectionState 。打开)
命令.Connection.Close();
}
" Ian Frawley" <叶** @ yeah.com>在消息中写道
news:Ot **************** @ TK2MSFTNGP14.phx.gbl ...SqlCommand command =新的
SqlCommand(" DBName..ProcessProcedure_Step1",this.c onnection);
尝试
{
command.CommandType = CommandType.StoredProcedure;
command.Connection .Open();
returnedRows = command.ExecuteNonQuery();
result ="执行成功..." ;;
}
catch(SqlException ex)
{
result =" SQLException: + ex.Message;
}
最后
{
if(command .Connection.State == ConnectionState.Open)
命令.Connection.Close();
}
" Stropher" < HM *** @ gmx.net>在消息中写道
新闻:11 ********************** @ g47g2000cwa.googlegr oups.com ...我只想在使用Visual c#
2005 Express Edition和SQL Server时调用存储过程
这是我的PressButton方法和后续方法:
//拿起来自用户的日期
DateTime = this.dateTimeDatum.Value;
string str = dt.ToShortDateString();
//执行存储过程 - 它获取DateTime as parameter
string commandText =" Exec DBName..ProcessProcedure_Step1''" +
DateTime.Parse(str)+"''" ;;
string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
我的ProcessProcedure
int returnedRows = 0;
string result ="" ;;
SqlCommand command = new SqlCommand();
command.Connection = this .connection; //连接已经实例化
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result ="执行成功..." ;;
connection.Close( );
}
catch(SqlException ex)
{
result =" SQLException: + ex.Message;
}
立即命令command.ExecuteNonQuery(),它跳转到
catch异常区域,显示消息 - 找不到存储过程...
我缺少什么技巧?
提前致谢
>
将日期作为参数包括在内:
command.Parameters.Add(" @ Parametername",DateTime.Parse(str));
>
" Ian Frawley" <叶** @ yeah.com>在消息中写道
新闻:OT ************** @ TK2MSFTNGP09.phx.gbl ...抱歉没有必要参考命令文本中的数据库
SqlCommand(" ProcessProcedure_Step1",this.connectio n);
尝试
{/> command.CommandType = CommandType.StoredProcedure;
command.Connection.Open();
returnedRows = command.ExecuteNonQuery();
result ="执行成功..." ;;
}
catch (SqlException ex)
{
result =" SQLException: + ex.Message;
}
最后
{
if(command .Connection.State == ConnectionState.Open)
命令.Connection.Close();
}
Ian Frawley <叶** @ yeah.com>在消息中写道
新闻:Ot **************** @ TK2MSFTNGP14.phx.gbl ...SqlCommand command = new
SqlCommand(" DBName..ProcessProcedure_Step1",this.c onnection);
尝试
{
command.CommandType = CommandType.StoredProcedure;
command.Connection.Open() ;
returnedRows = command.ExecuteNonQuery();
result ="执行成功..." ;;
}
catch(SqlException ex)
{
result =" SQLException: + ex.Message;
}
最后
{
if(command .Connection.State == ConnectionState.Open)
命令.Connection.Close();
}
" Stropher" < HM *** @ gmx.net>在消息中写道
新闻:11 ********************** @ g47g2000cwa.googlegr oups.com ...我只想在使用Visual c#
2005 Express Edition和SQL Server时调用存储过程
这是我的PressButton方法和后续方法:
//拿起来自用户的日期
DateTime = this.dateTimeDatum.Value;
string str = dt.ToShortDateString();
//执行存储过程 - 它获取DateTime as parameter
string commandText =" Exec DBName..ProcessProcedure_Step1''" +
DateTime.Parse(str)+"''" ;;
string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
我的ProcessProcedure
int returnedRows = 0;
string result ="" ;;
SqlCommand command = new SqlCommand();
command.Connection = this .connection; //连接已经实例化
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result ="执行成功..." ;;
connection.Close( );
}
catch(SqlException ex)
{
result =" SQLException: + ex.Message;
}
立即命令command.ExecuteNonQuery(),它跳转到
catch异常区域,显示消息 - 找不到存储过程...
我缺少什么技巧?
提前致谢
>
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
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
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
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
这篇关于未找到存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!