如何在页面上调用此过程。 [英] How to call This procedure on page.
本文介绍了如何在页面上调用此过程。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DROP PROCEDURE IF EXISTS hms.Select_LastDate_Result;
CREATE PROCEDURE hms.`Select_LastDate_Result`()
BEGIN
SELECT Current_Test_Date as 'Last_Date'
FROM patient_progress_tracking_details
ORDER BY Current_Test_Date DESC limit 1;
SELECT Test_Result as 'Result'
FROM patient_progress_tracking_details
ORDER BY Current_Test_Date DESC limit 1;
END;
这是我的cs文件..
this is my cs file..
protected void Imgbtnsave_Click(object sender, ImageClickEventArgs e)
{
MySqlConnection StrConnection = null;
MySqlCommand StrCommand = null;
try
{
StrConnection = new MySqlConnection();
StrConnection.ConnectionString = StrConn;
StrConnection.Open();
StrCommand = new MySqlCommand();
StrCommand.CommandType = CommandType.StoredProcedure;
StrCommand.CommandText = "Select_LastDate_Result";
StrCommand.Connection = StrConnection;
StrCommand.ExecuteNonQuery();
BindCarePlan();
}
catch (Exception ex)
{
obj.InfoEntry(DateTime.Now + " " + "BtnSave1_Click" + " " + "AccountBalance.aspx" + " " + ex.Message, "");
obj.InfoEntry(DateTime.Now + " " + ex.StackTrace, "");
Session["strerrormsg"] = DateTime.Now + " " + "BtnSave1_Click" + " " + "AccountBalance.aspx" + " " + ex.Message;
Session["strerrortrace"] = DateTime.Now + " " + ex.StackTrace;
Response.Redirect("ErrorPage.aspx");
}
finally
{
StrConnection.Close();
StrConnection.Dispose();
}
}
}
此代码不起作用..
this code is not working..
推荐答案
你会在网站上找到一些可以帮到你的链接/教程。
我刚刚在这里包含了一些 -
http://support.microsoft.com/kb/306574 [ ^ ]
http://www.macronimous.com/resources/calling_stored_procedures_from_ASP.NET_and_VB.NET.asp [ ^ ]
http://www.c-sharpcorner.com/UploadFile/gtomar/store dprocedure12052007003126AM / storedprocedure.aspx [ ^ ]
http://csharp-station.com/Tutorial/AdoDotNet/Lesson07 [ ^ ]
实际上这个问题之前也被问过 - 如何在asp.net c#代码中调用存储过程 [ ^ ]。
You will find a number of links / tutorials on the website that will help you.
I''ve just included a few here -
http://support.microsoft.com/kb/306574[^]
http://www.macronimous.com/resources/calling_stored_procedures_from_ASP.NET_and_VB.NET.asp[^]
http://www.c-sharpcorner.com/UploadFile/gtomar/storedprocedure12052007003126AM/storedprocedure.aspx[^]
http://csharp-station.com/Tutorial/AdoDotNet/Lesson07[^]
In fact this question was asked before as well - how to call stored procedure in asp.net c# code[^].
以下内容将帮助您:
MSDN:HOW TO:在Usi中调用ASP.NET中的SQL Server存储过程ng Visual C#.NET [ ^ ]
MSDN:如何:使用ADO.NET和Visual C#.NET调用参数化存储过程 [ ^ ]
ADO.NET:使用存储过程 [ ^ ]
Following will help you:
MSDN: HOW TO: Call SQL Server Stored Procedures in ASP.NET by Using Visual C# .NET[^]
MSDN: HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET[^]
ADO.NET : Using Stored Procedures[^]
StrConnection.ConnectionString = StrConn;
StrConnection.Open();
StrCommand = new MySqlCommand();
StrCommand.CommandType = CommandType.StoredProcedure;
StrCommand.CommandText =Select_LastDate_Result;
StrCommand.Connection = St rConnection;
代替以上代码使用以下:
StrCommand = new SqlCommand(Select_LastDate_Result,StrConnection );
cmd.CommandType = CommandType.StoredProcedure;
connection.Open();
StrConnection.ConnectionString = StrConn;
StrConnection.Open();
StrCommand = new MySqlCommand();
StrCommand.CommandType = CommandType.StoredProcedure;
StrCommand.CommandText = "Select_LastDate_Result";
StrCommand.Connection = StrConnection;
instead above code use following:
StrCommand= new SqlCommand("Select_LastDate_Result", StrConnection);
cmd.CommandType = CommandType.StoredProcedure;
connection.Open();
这篇关于如何在页面上调用此过程。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文