1、c#几种常用代码及c#与access数据库连接应用C# 字符串应用using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args) Console.WriteLine(输入一个字符串); string s = Console.ReadLine(); string s1; /* s1 = s.Substring(2, 2); s1 = s.Remove(
2、2, 3); s1 = s.Insert(3, 123); s1 = s.Replace(abcd, ABCD); char s2 = s.ToCharArray(2,3 ); for (int i = 0; i s.Length; i+) Console.WriteLine(s2i); int i = 98765; s1 = i.ToString(); s1 = s.ToUpper(); string s3 = s.Split(q); Console.WriteLine(s30); Console.WriteLine(s31); */ Console.WriteLine(s1); C#用户登
3、陆界面using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.OleDb;namespace 联系 public partial class Form1 : Form public Form1() InitializeComponent(); private void
4、 Form1_Load(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) string s = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=密码.mdb; OleDbConnection conn = new OleDbConnection(s); string sql = select* from mima where id= + textBox1.Text + and mi= + textBox2.Text + ; OleDbDa
5、taAdapter oda = new OleDbDataAdapter(sql, conn); DataSet ds = new DataSet(); oda.Fill(ds, tablet1); if (ds.Tables0.Rows.Count = 1) MessageBox.Show(登录成功!); else MessageBox.Show(登录失败, abcdefg,MessageBoxButtons.YesNo,MessageBoxIcon.Question); private void button1_Click() C#与ACCESS 数据库连接应用using System;u
6、sing System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.OleDb;namespace T3 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(ob
7、ject sender, EventArgs e) string s = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=123.mdb; OleDbConnection conn = new OleDbConnection(s); /- string Sql = select * from Student; OleDbDataAdapter oda = new OleDbDataAdapter(Sql, conn); /- DataSet ds = new DataSet(); oda.Fill(ds, t1); /- dataGridView1.D
8、ataSource = ds.Tablest1; private void button2_Click(object sender, EventArgs e) string s = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=123.mdb; OleDbConnection conn = new OleDbConnection(s); /- string Sql = select * from Student where ID=+textBox1 .Text+; OleDbDataAdapter oda = new OleDbDataAdapter
9、(Sql, conn); /- DataSet ds = new DataSet(); oda.Fill(ds, t1); /- dataGridView1.DataSource = ds.Tablest1; private void button3_Click(object sender, EventArgs e) sjb sjb1 = new sjb(); string sql = select * from Student where Sex= + textBox2.Text + ; dataGridView1.DataSource = sjb1.getsjb(sql); private
10、 void button4_Click(object sender, EventArgs e) sjb sjb2 = new sjb(); string sql = delete from Student where ID= + textBox3.Text + ; dataGridView1.DataSource = sjb2.getsjb(sql); private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) private void Form1_Load(object sender, EventArgs e)
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2