环境
- vs2015
操作过程
1、创建一个项目
文件--新建项目--控制台应用程序
2、安装sqlsugar
右键解决方案--管理NuGet程序包
搜索SqlSugar,安装。
安装成功后就可以在引用中找到了。
密码root
如何打开sqlserver配置管理系统
配置sqlserver
连不上
然后重启一下电脑(重启sqlserver服务)
连接数据库
工具-->连接到数据库
参考下面连接
wenku.baidu.com/view/163719…
但是我创建的是控制台应用程序,我没有使用form中,而是在program中这样写:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test2
{
class Program
{
static void Main(string[] args)
{
String str = "SELECT * FROM [student]";
test.ResM r1 = new test.ResM();
DataTable d1 = new DataTable();
d1 = r1.ExecuteQuery(str);
int n = d1.Rows.Count;
Console.WriteLine("你好,程序");
Console.WriteLine(n);
}
}
}
然后如下图开始执行(不调试)
我的表结构图如图: