能否在程序中创建存储过程?
也就是不在数据库那里创建,在程序中创建并调用。谢谢 问题点数:40、回复次数:6Top
1 楼TheAres(班门斧)回复于 2003-08-02 20:26:27 得分 10
你"create proc ****"这段Sql 语句还有吧。
产生一个sqlconnection,然后用connection产生一个sqlcommand对象,然后运行上面的sql语句就产生存储过程了。
Top
2 楼jianglinchun(萧丰)回复于 2003-08-02 20:37:39 得分 0
TheAres(班门斧):
能不能推荐点文章看看啊,就是有关于 sql 存储过程的。我现在迷糊得很哦。Top
3 楼TheAres(班门斧)回复于 2003-08-02 22:01:29 得分 0
论坛中例子就很多,用“存储过程”search一下看看。
Top
4 楼dahuzizyd(你就是我心中的女神)回复于 2003-08-02 22:04:19 得分 30
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");
SqlCommand salesCMD = new SqlCommand("SalesByCategory", nwindConn);
salesCMD.CommandType = CommandType.StoredProcedure; //注意这一句
SqlParameter myParm = salesCMD.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 15);
myParm.Value = "Beverages";
nwindConn.Open();
SqlDataReader myReader = salesCMD.ExecuteReader();
Console.WriteLine("{0}, {1}", myReader.GetName(0), myReader.GetName(1));
while (myReader.Read())
{
Console.WriteLine("{0}, ${1}", myReader.GetString(0), myReader.GetDecimal(1));
}
myReader.Close();
nwindConn.Close();Top
5 楼jianglinchun(萧丰)回复于 2003-08-03 05:56:14 得分 0
嗬嗬,谢谢班门斧了,我后来搜索了一下,对于存储过程的了解有很大的进步,今天还突破了在access中使用存储过程这个小问题。:DTop




