All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
如何在web.config中建立公用的的数据库连接_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/6 9:11:58 Browse times: 308 Comment times: 0

如何在web.config中建立公用的的数据库连接_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

如何在web.config中建立公用的的数据库连接_[Asp.Net教程]

































public SqlDataReader GetReviews(int productID) {




// 创建Connection和Command对象实例
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings[ConnectionString]);
SqlCommand myCommand = new SqlCommand(ReviewsList, myConnection);




myCommand.CommandType = CommandType.StoredProcedure;




// 参数
SqlParameter parameterProductID = new SqlParameter(@ProductID, SqlDbType.Int, 4);
parameterProductID.Value = productID;
myCommand.Parameters.Add(parameterProductID);




// 执行
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);




// 返回结果
return result;
数据库连接;return true>


































There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.