資源簡介
簡單的 C#操作Mysql,可以運行,里面有增刪查改等主要借助于MySql.Data.dll腳本,不過我的工程里的Debug文件夾里已經(jīng)含有此dll只要引用就可以使用了

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?MySql.Data;
using?System.Windows.Forms;
using?System.Collections;
namespace?WindowsFormsApplication9
{
????public?partial?class?Form1?:?Form
????{
????????Mysql?mysql?=?new?Mysql();
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?btn_connect_Click(object?sender?EventArgs?e)
????????{
????????????bool?b=mysql.connect();//建立數(shù)據(jù)庫連接
????????????if?(b)
????????????{
????????????????MessageBox.Show(“數(shù)據(jù)庫連接成功“);
???????????????????
????????????}
????????????else
????????????{
????????????????MessageBox.Show(“數(shù)據(jù)庫連接失敗“);
????????????}
????????}
????????private?void?btn_queryAll_Click(object?sender?EventArgs?e)
????????{
????????????string?str_sql?=?“select?*?from?student“;
????????????ArrayList?arraylist=mysql.queryAll(str_sql);
????????????foreach(string?s?in?arraylist)????
????????????{
????????????????this.richTextBox1.Text+=?s;
????????????}???????????
????????}
????????private?void?btn_add_Click(object?sender?EventArgs?e)
????????{
????????????string?str_sql?=?“insert?into?student(namesexclass)?values(‘小花‘‘女‘‘二期班‘)?“;
????????????int?t?=?mysql.operateSql(str_sql);
????????????if?(t?!=?1)
????????????{
????????????????MessageBox.Show(“插入失敗“);
????????????}
????????????else
????????????{
????????????????MessageBox.Show(“插入成功“);
????????????}
????????}
????????//“delete?from?deviceConvert?where?序號?=?“?+?r.ToString();
????????private?void?btn_delet_Click(object?sender?EventArgs?e)
????????{
????????????string?str_sql?=?“delete?from?student?where?id=3?“;
????????????int?t?=?mysql.operateSql(str_sql);
????????????Console.WriteLine(t.ToString()+“?t“);
????????????if?(t?!=?1)
????????????{
????????????????MessageBox.Show(“刪除失敗“);
????????????}
????????????else
????????????{
????????????????MessageBox.Show(“刪除成功“);
????????????}
????????}
????????private?void?btn_update_Click(object?sender?EventArgs?e)
????????{
????????????string?str_sql?=?“update?student?set?name=‘李四‘?where?id=1“;
????????????int?t?=?mysql.operateSql(str_sql);
????????????if?(t?!=?1)
????????????{
????????????????MessageBox.Show(“更新失敗“);
????????????}
????????????else
????????????{
????????????????MessageBox.Show(“更新成功“);
????????????}
????????}
????????private?void?btn_add_transaction_Click(object?sender?EventArgs?e)
????????{
????????????string?str_sql?=?“insert?into?student(namesexclass)?values(‘小花‘‘女‘‘二期班‘)?“;
????????????int?t?=?mysql.operateSqlTransaction(str_sql);
????????????if?(t?!=?1)
????????????{
????????????????MessageBox.Show(“插入失敗“);
????????????}
????????????else
????????????{
????????????????MessageBox.Show(“插入成功“);
????????????}
????????}
????????private?void?btn_delet__transaction_Click(object?sender?EventArgs?e)
????????{
????????????string
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????294912??2013-05-22?17:21??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\bin\Debug\MySql.Data.dll
?????文件??????15360??2018-04-08?15:06??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.exe
?????文件??????38400??2018-04-08?15:06??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.pdb
?????文件??????11600??2018-04-08?15:06??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.vshost.exe
?????文件????????490??2015-10-22?09:54??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\bin\Debug\WindowsFormsApplication9.vshost.exe.manifest
?????文件???????3971??2018-04-08?15:03??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Form1.cs
?????文件???????7769??2018-04-08?15:03??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Form1.Designer.cs
?????文件???????5817??2018-04-08?15:03??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Form1.resx
?????文件??????10577??2018-04-08?15:05??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Mysql.cs
?????文件?????294912??2013-05-22?17:21??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\MySql.Data.dll
?????文件???????2867??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6585??2018-04-08?15:06??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????1314??2018-04-08?15:06??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\WindowsFormsApplication9.csproj.FileListAbsolute.txt
?????文件????????975??2018-04-08?15:03??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\WindowsFormsApplication9.csproj.GenerateResource.Cache
?????文件??????16089??2018-04-08?11:34??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\WindowsFormsApplication9.csprojResolveAssemblyReference.cache
?????文件??????15360??2018-04-08?15:06??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\WindowsFormsApplication9.exe
?????文件????????180??2018-04-08?15:03??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\WindowsFormsApplication9.Form1.resources
?????文件??????38400??2018-04-08?15:06??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\WindowsFormsApplication9.pdb
?????文件????????180??2018-04-08?11:34??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\WindowsFormsApplication9.Properties.Resources.resources
?????文件????????505??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Program.cs
?????文件???????1398??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Properties\AssemblyInfo.cs
?????文件???????2900??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Properties\Resources.Designer.cs
?????文件???????5612??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Properties\Resources.resx
?????文件???????1111??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Properties\Settings.Designer.cs
?????文件????????249??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\Properties\Settings.settings
?????文件???????3903??2018-04-08?11:34??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\WindowsFormsApplication9.csproj
?????文件????????914??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9.sln
????..A..H.?????22016??2018-04-08?15:08??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9.suo
?????目錄??????????0??2018-04-08?10:26??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug\TempPE
?????目錄??????????0??2018-04-08?15:06??C#操作MysSQL數(shù)據(jù)庫\WindowsFormsApplication9\obj\x86\Debug
............此處省略10個文件信息
- 上一篇:C# ID卡識別硬件讀寫
- 下一篇:簡單實現(xiàn)C# ajax demo
評論
共有 條評論