资源窗口视图
脚本:
-
导入dll文件。
-
导入脚本SqlAccess
-
使用
主要功能
创建表
private void CreateTable()
{
SqlAccess sql = new SqlAccess();
sql.CreateTable("Infomation", new string[] { "name", "id", "password" }, new string[] { "text", "int", "text" });
sql.Close();
}
插入数据
private void Insert()
{
SqlAccess sql = new SqlAccess();
sql.InsertInto("login", new string[] {"name","id","password" },new string[] {"456","2","456" });
sql.Close();
}
删除数据
private void Delete()
{
SqlAccess sql = new SqlAccess();
sql.Delete("login", new string[] {"id"}, new string[] {"2"});
sql.Close();
}
更新数据
private void UpdateInfo()
{
SqlAccess sql = new SqlAccess();
sql.UpdateInto("login", new string[] { "name", "id", "password" }, new string[] { "789", "789", "789" }, "id", "1");
sql.Close();
}
查找数据
private void Select()
{
SqlAccess sql = new SqlAccess();
DataSet ds = sql.SelectWhere("login", new string[] { "name", "password" }, new string[] { "id" }, new string[] { "=" }, new string[] { "1" });
if (ds != null)
{
DataTable table = ds.Tables[0];
foreach (DataRow row in table.Rows)
{
foreach (DataColumn column in table.Columns)
{
print(row[column]);
}
}
}
sql.Close();
}
private void SelectOne()
{
SqlAccess sql = new SqlAccess();
DataSet ds = sql.SelectWhere("login", new string[] { "name", "password" }, new string[] { "name" }, new string[] { "=" }, new string[] { "123" });
if (ds != null)
{
DataTable table = ds.Tables[0];
string str = table.Rows[0][table.Columns[1]].ToString();
}
sql.Close();
}
数据库表中结构图