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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - 紫微星

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();