sqlhelper是一个完全开源的源码组件,使用sqlhelper可以方便操作sqlserver、oracle、access等数据库。语法简单,提高性能。
SqlHelper 的两种写法:
SqlHelper make in Visual studio 2010.support sqlserver,access,oracle databases.
多语句或事务方式:
using (SqlConnection conn = SqlServerHelper.GetConnection())
{
conn.Open();
SqlServerHelper.ExecuteNonQuery(conn,CommandType.Text,"insert into [students] values(@student_name,@class)",
SqlServerHelper.CreateInputParameter("@student_name", SqlDbType.NVarChar, 100, txt_student_name_sqlserver.Text),
SqlServerHelper.CreateInputParameter("@class", SqlDbType.NVarChar, 100, txt_class_sqlserver.Text)
);
g1.DataSource = SqlServerHelper.ReadTable(conn, CommandType.Text, "select * from [students]", null);
g1.DataBind();
}
简单方式:
SqlServerHelper.ExecuteNonQuery(CommandType.Text,"insert into [students] values(@student_name,@class)",
SqlServerHelper.CreateInputParameter("@student_name", SqlDbType.NVarChar, 100, txt_student_name_sqlserver.Text),
SqlServerHelper.CreateInputParameter("@class", SqlDbType.NVarChar, 100, txt_class_sqlserver.Text)
);