惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 紫微星

Python ImportError: No module named arcgisscripting ENVI遥感影像处理实用手册PDF下载 卡巴斯基许可Key需求登记表 ArcGIS Desktop 9.3 中文运行环境|中文补丁 胡适:赠与今年的大学毕业生 ArcMap打不开且出现提示(Hostname:Not_Set)的解决方法 QQ超级群问题反馈 “GIS空间分析-使用ArcGIS”课程资料完整打包下载,感谢杨克诚老师! ArcGIS 9.3 下载(包含ArcGIS Desktop、ArcGIS Engine、ArcGIS Server、ArcSDE、workstation) ArcGIS中查看metadata显示"warning+乱码"的解决方法 [请您去投票]ESRI中国社区2008年度优秀会员评选 [新年快乐!] Modeling Our World三版合集 下载[2009-4-27更新] GIS界首个超级QQ群——“GIS人@E家”,欢迎GIS朋友们加入! 深入研究VS2008中的JavaScript编辑调试器 AE初学的一点理解及有关QI(接口查询) 引用与using的什么区别 控件和组件的差别[转] 平时遇到的GISblog收集 平时遇到的C#和VS问题及解决方法记录 - 紫微星 - 博客园
ADO.NET入门学习备忘
紫微星 · 2008-09-11 · via 博客园 - 紫微星


//连接字符串_直接写
string conStr = "Data Source=computer;Initial Catalog=AdoTest;Integrated Security=True; Persist Security Info=True;";

//连接字符串_写在Web.Config里
string conStr = System.Configuration.ConfigurationManager.ConnectionStrings["constring"].ToString();
//Web.Config里设置
<connectionStrings>
    
<add name="constring" connectionString="Data Source=visingcomputer;Initial Catalog=AdoTest;Integrated Security=True; Persist Security Info=True;"/>
  
</connectionStrings>

//连接数据库
        string conStr =System.Configuration.ConfigurationManager.ConnectionStrings[1].ToString();
        SqlConnection sqlCon 
= new SqlConnection(conStr);
        sqlCon.Open();
        
this.Label1.Text = sqlCon.State.ToString();

        
//插入数据
        string sqlIntoCmd="insert into info values('123','地理学','g')";
        SqlCommand sqlInto 
= new SqlCommand(sqlIntoCmd, sqlCon); 
        sqlInto.ExecuteNonQuery();  
//这句执行后,数据才真正插入数据库中.

        
////使用SqlDataReader显示数据
        //string sqlSelectCmd = "select * from info";
        
//SqlCommand sqlSelect = new SqlCommand(sqlSelectCmd, sqlCon);
        
//SqlDataReader sqlDr=sqlSelect.ExecuteReader();
        
//while (sqlDr.Read())
        
//{
        
//    Response.Write(sqlDr[0]);
        
//    Response.Write(sqlDr[1]);
        
//    Response.Write(sqlDr[2]);
        
//    Response.Write("<br />");
        
//}
        
//sqlDr.Close();


        
//使用SqlDataAdapter,DataSet显示数据
        string sqlSelectCmd = "select * from info";
        SqlDataAdapter da 
= new SqlDataAdapter(sqlSelectCmd, sqlCon);        
        DataSet ds 
= new DataSet();
        da.Fill(ds, 
"info");
        
if (ds.Tables[0].Rows.Count == 0)
        
{
            Response.Write(
"NOdata");
        }

        
else
        
{
            
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            
{
                Response.Write(ds.Tables[
0].Rows[i][0]);
                Response.Write(ds.Tables[
0].Rows[i][1]);
                Response.Write(ds.Tables[
0].Rows[i][2]);
                Response.Write(
"<br />");
            }
            
        }

       

        
////使用SqlDataAdapter,SqlCommandBuilder,DataSet插入数据
        //string sqlSelectCmd = "select * from info";        
        
//SqlDataAdapter da = new SqlDataAdapter(sqlSelectCmd, sqlCon);
        
//SqlCommandBuilder cb = new SqlCommandBuilder(da);
        
//DataSet ds = new DataSet();
        
//da.Fill(ds, "info");
        
//DataRow newrow = ds.Tables[0].NewRow();
        
//newrow[0] = "text";
        
//newrow[1] = "text";
        
//newrow[2] = "text";
        
//ds.Tables[0].Rows.Add(newrow);
        
//da.Update(ds, "info");

        sqlCon.Close();