码迷,mamicode.com
首页 > 数据库 > 详细

网页调用SQL的数据。

时间:2016-04-16 07:13:19      阅读:572      评论:0      收藏:0      [点我收藏+]

标签:

1..链接SQL

1.1  链接字符串

     

WINDOWS集成验证方式:

server=localhost;(ID地址或者主机名)    initial cataloh = pubs;(数据库名称); integrated security=ture;(建立安全的链接)

 

SQL 验证方式

server=localhost;(ID地址或者主机名)    initial cataloh = pubs;(数据库名称)  user id= ; password=; 

 

1.2建立链接

using system.data.sqlclient; //导入SQLCLIENT命名空间

string constr= data source=(local); initial catalog=; integrated security="true"  

sqlconnection conn=new sqlconnection(conste); //建立链接对象

 

EG. 数据库更新操作

string str = "Data Source=.;Initial Catalog=yao;User ID=sa;Password=123";
SqlConnection con = new SqlConnection(str);
string strSql = "update yonghu set username=‘" + gainame.Text + "‘,password=‘" + gaipass.Text + "‘,sex=‘" + gaisex.Text + "‘,youxiang=‘" + gaiyouxiang.Text + "‘ , dianhua=‘" + gaiphone.Text + "‘ where username=‘" + xiugainame.Text + "‘";
SqlCommand cmd = new SqlCommand(strSql, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();

 

 

熟悉数据库操作。实现数据库调取图片路径。

网页调用SQL的数据。

标签:

原文地址:http://www.cnblogs.com/huzhenkai/p/5397019.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!