c# SQL数据库远程连接及配置方法
首先配置SQLSERVER2005:
打开”Microsoft SQL Server Management Studio“ 直接用Windows 用户连接进入,再在“安全性”中的“登录名”内的“新建登录名”,你就对应的添好“确定”就可以了。
再在你对应的“数据库”里“安全性”用户,把你建的用户添加进去。
关键地方,查看“服务器 属性”在 “安全性”选上 “SQL Server 和 Windows 身份验证模式”点 “确定”系统会提示你重新启动SQL Server 你“停止”重启一下就配好了。
接着看C#连接SQL Server2005的代码语句:
strcon = strcon + @"Data Source=" + strcons[0];
strcon = strcon + "," + strcons[2] + ";";
strcon = strcon + "Network Library=" + strcons[1] + ";";
strcon = strcon + "Initial Catalog=" + strcons[3] + ";";
strcon = strcon + "User ID=" + strcons[4] + ";";
strcon = strcon + "Password=" + strcons[5] + ";";
strcon = strcon + "Persist Security Info=True";
.站
strcons[0] 服务器名称,一般为机器的IP
strcons[1]协议DBMSSOCN(为tcp/ip协议)
strcons[2]]端口号,一般为1433
strcons[3] 数据库名
strcons[4] 用户名
strcons[5]密码
端口号也要配置一下:
在控制面板里的服务和应用程序中的SQL Server配置管理中的SQL Server 2005网络配置内的SQL Www_Chinaz_com Server2005的协议TCP/IP默认为已禁用,在它的属性设置它的端口号为1433 “确定” 启动。
相关文档:
定义:
create table 表名(列名1 类型 [not null] [,列名2 类型] [not null],···) [其他参数]
修改:
alter table 表名 add 列名 类型
alter table 表名 rename column 原列名 to 新列名
alter table 表名 alter column 列名 类型 [(宽度) [,小数位]]
alter table 表名 drop column 列名
......
This has some predictable results that we can use for building queries. The root is always of the form (left = 1, right = 2 * (SELECT COUNT(*) from TreeTable)); leaf nodes always have (left + 1 = right); the BETWEEN predicate defines the subtrees; and so on. Here are some common queries that you can ......
发送端以163为例
一、asp.net版 using System.Web.Mail; //命名空间引用
c#
MailMessage mail = new MailMessage();
mail.To = "shadow103@qq.com"; //接受人的邮箱
& ......
c# SQL数据库远程连接及配置方法
一:C# 连接SQL数据库
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;
Server=myServerAddress;D ......