C#——调用存储过程方法
下面是我自己总结的一个比较简单的c#调用SQL Server 2005存储过程的小例子,主要是介绍整个过程,有问题的话请大虾们指导,谢谢~
作者:shinehoo
1)存储过程这样写的
ALTER PROCEDURE dbo.procShowLog
(
@StartTime datetime,
@EndTime datetime,
@LogSite varchar(20),
@UserName varchar(30)
)
AS
/* SET NOCOUNT ON
*/
BEGIN
IF(@UserName = ‘’)
BEGIN
select *
from tbLog where LogInTime
> @StartTime and LogInTime < @EndTime and LogSite = @LogSite;
END;
ELSE
BEGIN
select * from tbLog where LogInTime
> @StartTime and LogInTime < @EndTime and LogSite = @LogSite and UserName
= @UserName;
END;
RETURN
END;
2)C#里面有各类专门调用存储过程
/// <summary>
/// 执行存储过程返回一个表。
/// </summary>
/// <param
name="proName">存储过程名</param>
/// <param
name="paraValues">参数值列表</param>
/// <returns>DataTable对象</returns>
public static DataTable getDataTable(string proName, SqlParameter[]
paraValues)
{
SqlConnection
sqlcon = getConnection();
&nbs
相关文档:
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;//Cryptography密码术
namespace DAL
{
public class Enc ......
关于使用到了两个C#关键字this和base。
1,C# "this " keyword
其作用引用类的当前实例,其实看了下面这个例子就好理解了。
主要三个作用:当前实例、参数传递和索引器
1.1 当前实例
class Team
{
///成员变量
private string name;
///构造函数
......
Observer.cs
using System;
using System.Text;
using System.Collections.Generic;
namespace Observer
{
public interface ISubject
{
void RegisterObserver(IOvserver o);
& ......
1 创建C# DLL,需要指定应用类型为“类库”,代码:
namespace CSLib
{
public class Class1
{
private string name;
public string Name
......