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

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
博客园 - 【当耐特】
小众软件
小众软件
博客园 - Franky
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
雷峰网
雷峰网
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Last Week in AI
Last Week in AI
博客园_首页
月光博客
月光博客
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
云风的 BLOG
云风的 BLOG
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Docker
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
DataBreaches.Net
S
Security @ Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
TaoSecurity Blog
TaoSecurity Blog
S
Security Affairs
Y
Y Combinator Blog
O
OpenAI News
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
K
Kaspersky official blog
Cloudbric
Cloudbric

博客园 - L.Net

sql server不存在或拒绝访问【转】 更新Oracle中的long字段 Ora-28000 the account is locked windows2003与文件共享有关的几个进程 [转]“您试图从目录中执行CGI、ISAPI 或其他可执行程序...” 博文阅读密码验证 - 博客园 博文阅读密码验证 - 博客园 【转】RDLC使用经验 Windows XP .net3.5 环境搭建 showModalDialog数据缓存问题 - L.Net - 博客园 November Report Viewer工具栏显示英文 (转)Reference Equals,==,Equals sql declare声明变量 windows2003计划任务不能启动,"指定的错误是:0x80070005: 拒绝访问" 不可恢复的生成错误 还是得继续努力 每天知道多一点--[转]静态构造函数 每天知道多一点
每天知道多一点(二)
L.Net · 2008-06-17 · via 博客园 - L.Net

  决定将一些简单的程序放在这里.可能很简单,但是要备忘.是今后学习的参考.主要还是积累.
  1:一段简单的控制台程序

 static void Main(string[] args)
        
{
            
bool b = SearchString();
            Console.WriteLine(
"The result is "+b);
        }

        
public static bool SearchString()
        
{
            
string FileContent;
            
//打开文件
            System.IO.FileStream mystream = new System.IO.FileStream("D:\\test.txt", System.IO.FileMode.Open);
            System.IO.StreamReader mystreamReader 
= new System.IO.StreamReader(mystream);
            
//读取文件

            FileContent 
= mystreamReader.ReadToEnd();
            
//查询特定的词汇
            int ind = FileContent.IndexOf("work");
            
if (ind>0)
                
return true;
            
else
                
return false;
            
//关闭
            mystreamReader.Close();

2:一段简单的数据库操作

 private void button1_Click(object sender, EventArgs e)
        
{
            openFileDialog1.InitialDirectory 
= @"C:\Program files\";
            openFileDialog1.Filter 
= "mdb files(*.mdb)|*.mdb|All files(*.*)|*.*";
            openFileDialog1.FileName 
= "";
            openFileDialog1.FilterIndex 
= 2;
            openFileDialog1.RestoreDirectory 
= true;

            
if (openFileDialog1.ShowDialog() == DialogResult.OK)
            
{
                textBox1.Text 
= openFileDialog1.FileName;
            }

        }


        
private void button2_Click(object sender, EventArgs e)
        
{
            
//OleDbConnection conn = new OleDbConnection();
            
//string str = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + textBox1.Text + "; " + "User ID=admin;Jet OLEDB:database Password=gongdiansuo;Persist Security Info=true";
            
//OleDbConnection conn = new OleDbConnection(str);
            
//string sql = "UPDATE a30 SET 表号 = 出厂编号;";
            
//OleDbCommand cmd = new OleDbCommand(sql,conn);
            
//conn.Open();
            if (textBox1.Text == "")
            
{
                MessageBox.Show(
"请选择数据库所在的位置""info");
            }

            
else
            
{
                
string str = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + textBox1.Text + "" + "User ID=admin;Jet OLEDB:database Password=gongdiansuo;Persist Security Info=true";
                OleDbConnection conn 
= new OleDbConnection(str);
                
string sql = "UPDATE a30 SET 表号 = 出厂编号;";
                OleDbCommand cmd 
= new OleDbCommand(sql, conn);
                
//conn.Open();
                if (checkBox1.Checked)
                
{
                    
try
                    
{
                        conn.Open();
                        cmd.ExecuteNonQuery();
                    }

                    
catch (Exception ex)
                    
{
                        MessageBox.Show(ex.Message);
                    }

                    
finally
                    
{
                        conn.Close();
                        MessageBox.Show(
"update successfully""info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                }

                 
if(checkBox2.Checked)
                
{
                   
                    
string insert = "UPDATE A30 SET A30.[日光灯(kW)] = @light, A30.[日光灯(数量)] = @lightnum, A30.[电视机(kW)] = @tv, A30.[电视机(数量)] = @tvnum;";
                    OleDbCommand cmd1 
= new OleDbCommand(insert, conn);
                    cmd1.Parameters.AddWithValue(
"@light", textBox2.Text);
                    cmd1.Parameters.AddWithValue(
"@lightnum",textBox3.Text);
                    cmd1.Parameters.AddWithValue(
"@tv",textBox4.Text);
                    cmd1.Parameters.AddWithValue(
"@tvnum",textBox5.Text);

                    
try
                    
{
                        conn.Open();
                        cmd1.ExecuteNonQuery();
                    }

                    
catch (Exception ex)
                    
{
                        MessageBox.Show(ex.Message);
                    }

                    
finally
                    
{
                        conn.Close();
                        MessageBox.Show(
"insert successfully""info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }


                }

                
else
                
{
                    MessageBox.Show(
"未选择任何操作""info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

            }

            

        }


        
private void button3_Click(object sender, EventArgs e)
        
{
            
this.Close();
        }


        
private void checkBox2_CheckedChanged(object sender, EventArgs e)
        
{
            
if (textBox2.Enabled == false)
                textBox2.Enabled 
= true;
            
else
                textBox2.Enabled 
= false;

            
if (textBox3.Enabled == false)
                textBox3.Enabled 
= true;
            
else
                textBox3.Enabled 
= false;

            
if (textBox4.Enabled == false)
                textBox4.Enabled 
= true;
            
else
                textBox4.Enabled 
= false;

            
if (textBox5.Enabled == false)
                textBox5.Enabled 
= true;
            
else
                textBox5.Enabled 
= false;
            
        }