asp教程.net 连接mssql 2005代码与实例
SqlConnection sql = new SqlConnection(@"server=.sql2005;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=test;Data Source=7085360CB900427");
try
{
sql.Open();
if (sql.State == ConnectionState.Open)
label1.Text = "连接成功!";
}
catch (SqlException S)
{
MessageBox.Show(S.Message);}
finally
{
sql.Close();
sql.Dispose();
}
//asp.net教程连接mssql 2005方法二
private void button_logIn_Click(object sender, EventArgs e)
{
string connectionString = "Data Source=(local);Initial Catalog=system;"
+ "Integrated Security=SSPI;";
SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.Open();
if (connection.State == ConnectionState.Open)
{
SqlCommand selectCmd = new SqlCommand("select * from User where 用户名 = ' " + this.textBox_user.Text + " ' ", connection);
SqlDataReader mysql教程reader = selectCmd.ExecuteReader();
if (mysqlreader.Read())
{
if (this.textBox_password.Text == mysqlreader["密码"].ToString())
{
uiLogin.UserName = this.textBox_user.Text;
uiLogin.Password = this.textBox_password.Text;this.DialogResult = DialogResult.OK;
}
else
{
nLoginCount++;
if (nLoginCount == MAX_LOGIN_COUNT)
{
this.DialogResult = DialogResult.Cancel;
}
else
{
MessageBox.Show("Invalid user name and password!");
this.textBox_user.Focus();
}
}}
else
{
throw new Exception("没有该用户 ");
}
}
}
catch
{
}
connection.Close();
}
//其它的mssql 2005与.net连接方法
使用aspnet_regsql.exe 命令创建数据库教程;
2,连接字符串:
connectionString="Data Source=localhost;
Initial Catalog=apps教程ervicesdb;
Integrated Security=True"
providerName="System.Data.SqlClient"/>
注意这里添加连接字符串的表达式,使用的是集成Windows身份验证(using Windows Integrated Security)的方式
connectionString="Data Source=localhost;
Initial Catalog=appservicesdb;
Integrated Security=True"
providerName="System.Data.SqlClient"/>
另外的一种方式,使用SQL Server的身份认证,可以使用下面的表达式:
providerName="System.Data.SqlClient"
connectionString= "server=myserver;database=Products;uid=salesUser;pwd=sellMoreProducts" />
%>
敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载像素火影骨架佐助 (Perseverance Fire Shadow)手机版v1.16
下载要塞英雄 安卓版v33.20.0-39082670-Android
下载梦想城镇vivo最新版本 安卓版v12.0.1
梦想城镇vivo版是这款卡通风模拟经营类手游的渠道服版本,玩
怦然心动的瞬间 安卓版v1.0
怦然心动的瞬间是一款真人向的恋爱互动游戏,在游戏中玩家将扮演
曼尼汉堡店游戏 安卓版v1.0.3
曼尼汉堡店是一款非常好玩的精品恐怖类型冒险游戏,在这款游戏中
现代总统模拟器去广告版 安卓版v1.0.46
现代总统模拟器是一款休闲养成类游戏,可能对于不少的玩家来说都
现代总统模拟器付费完整版 安卓版v1.0.46
现代总统模拟器高级版在商店是需要付费的,相对于普通版本,高级