xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

資源簡(jiǎn)介

對(duì)MySQL數(shù)據(jù)的操作,因數(shù)據(jù)結(jié)構(gòu)比較簡(jiǎn)單,需自建mysql數(shù)據(jù)庫(kù)表

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?MySql.Data.MySqlClient;

namespace?My_SQL
{
????public?partial?class?Form1?:?Form
????{
????????//public?object?sender;
????????//public?EventArgs?e;

????????public?Form1()
????????{
????????????InitializeComponent();
????????????textBox1.Text?=?“test“;
????????????textBox2.Text?=?“root“;
????????????textBox3.Text?=?“1234qwer“;

????????????//創(chuàng)建庫(kù)
????????????textBox4.Text?=?““;
????????????textBox5.Text?=?“root“;
????????????textBox6.Text?=?“1234qwer“;

????????????//創(chuàng)建表
????????????textBox7.Text?=?“dog_name“;
????????????textBox8.Text?=?“dog_sex“;
????????????textBox9.Text?=?“dog_old“;


????????????//初始化表格表頭
????????????this.listView1.Columns.Add(“id“?120?HorizontalAlignment.Left);?//一步添加
????????????this.listView1.Columns.Add(“姓名“?120?HorizontalAlignment.Left);?//一步添加
????????????this.listView1.Columns.Add(“年齡“?120?HorizontalAlignment.Left);?//一步添加
????????}

????????//【函數(shù)】連接數(shù)據(jù)庫(kù)
????????MySqlConnection?MySQL_Connect()
????????{
????????????//打開通道,建立連接,可能出現(xiàn)異常使用try?catch語句
????????????MySqlConnection?conn;
????????????string?connstr?=?“data?source=localhost;database=“?+?textBox1.Text?+?“;?user=“?+?textBox2.Text?+?“;?password=“?+?textBox3.Text?+?“;?pooling=false;charset=utf8“;//pooling代表是否使用連接池
????????????conn?=?new?MySqlConnection(connstr);
????????????conn.Open();

????????????try
????????????{
????????????????Console.WriteLine(“已經(jīng)建立連接“);
????????????????return?conn;
????????????}
????????????catch?(MySqlException?ex)
????????????{
????????????????MessageBox.Show(ex.Message);
????????????????return?null;
????????????}
????????}


????????//【函數(shù)】讀MySQL數(shù)據(jù)庫(kù)
????????MySqlConnection?MySQL_Read(string?sql?ref?MySqlDataReader?reader)
????????{
????????????//連接數(shù)據(jù)庫(kù)
????????????MySqlConnection?conn?=MySQL_Connect();
????????????MySqlCommand?cmd;

????????????//發(fā)送指令
????????????cmd?=?new?MySqlCommand(sql?conn);

????????????//執(zhí)行ExecuteReader()返回一個(gè)MySqlDataReader對(duì)象
????????????reader?=?cmd.ExecuteReader();

????????????//返回讀數(shù)據(jù)
????????????return?conn;
????????}

????????//【函數(shù)】寫MySQL數(shù)據(jù)庫(kù)
????????void?MySQL_Execute(MySqlConnection?connstring?sql)
????????{
????????????//發(fā)送指令
????????????MySqlCommand?cmd;

????????????cmd?=?new?MySqlCommand(sql?conn);

????????????//執(zhí)行插入、刪除、更改語句。執(zhí)行成功返回受影響的數(shù)據(jù)的行數(shù),返回1可做true判斷。執(zhí)行失敗不返回任何數(shù)據(jù),報(bào)錯(cuò),下面代碼都不執(zhí)行
????????????cmd.ExecuteNonQuery();
????????}


????????//連接數(shù)據(jù)庫(kù)
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????MySQL_Connect();
????????????MessageBox.Show(“連接數(shù)據(jù)庫(kù)成功!“);
????????}

????????//讀數(shù)據(jù)庫(kù)表
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????//發(fā)送指令
????????????string?sql?=?“select?*?from?test.name“;
????????????MySqlDataReader?r

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

????..A..H.?????49152??2020-10-30?21:47??My?SQL\.vs\My?SQL\v14\.suo

?????文件????????189??2020-03-14?19:26??My?SQL\My?SQL\App.config

?????文件??????17408??2020-10-30?21:47??My?SQL\My?SQL\bin\Debug\My?SQL.exe

?????文件????????189??2020-03-14?19:26??My?SQL\My?SQL\bin\Debug\My?SQL.exe.config

?????文件??????28160??2020-10-30?21:47??My?SQL\My?SQL\bin\Debug\My?SQL.pdb

?????文件??????22696??2020-10-30?21:47??My?SQL\My?SQL\bin\Debug\My?SQL.vshost.exe

?????文件????????189??2020-03-14?19:26??My?SQL\My?SQL\bin\Debug\My?SQL.vshost.exe.config

?????文件????????490??2019-03-19?12:46??My?SQL\My?SQL\bin\Debug\My?SQL.vshost.exe.manifest

?????文件?????457216??2015-07-03?16:52??My?SQL\My?SQL\bin\Debug\MySql.Data.dll

?????文件??????10152??2020-03-18?23:01??My?SQL\My?SQL\Form1.cs

?????文件??????17541??2020-03-15?16:30??My?SQL\My?SQL\Form1.Designer.cs

?????文件???????6017??2020-03-15?16:30??My?SQL\My?SQL\Form1.resx

?????文件???????4011??2020-03-14?20:10??My?SQL\My?SQL\My?SQL.csproj

?????文件?????457216??2015-07-03?16:52??My?SQL\My?SQL\MySql.Data.dll

?????文件???????1464??2020-03-14?23:00??My?SQL\My?SQL\obj\Debug\DesignTimeResolveAssemblyReferences.cache

?????文件???????7181??2020-03-14?19:35??My?SQL\My?SQL\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

?????文件????????659??2020-10-30?21:47??My?SQL\My?SQL\obj\Debug\My?SQL.csproj.FileListAbsolute.txt

?????文件???????1012??2020-03-15?16:33??My?SQL\My?SQL\obj\Debug\My?SQL.csproj.GenerateResource.Cache

?????文件??????11726??2020-03-14?20:10??My?SQL\My?SQL\obj\Debug\My?SQL.csprojResolveAssemblyReference.cache

?????文件??????17408??2020-10-30?21:47??My?SQL\My?SQL\obj\Debug\My?SQL.exe

?????文件??????28160??2020-10-30?21:47??My?SQL\My?SQL\obj\Debug\My?SQL.pdb

?????文件????????180??2020-03-15?16:33??My?SQL\My?SQL\obj\Debug\My_SQL.Form1.resources

?????文件????????180??2020-03-14?20:10??My?SQL\My?SQL\obj\Debug\My_SQL.Properties.Resources.resources

?????文件??????????0??2020-03-14?19:26??My?SQL\My?SQL\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

?????文件??????????0??2020-03-14?19:26??My?SQL\My?SQL\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

?????文件??????????0??2020-03-14?19:26??My?SQL\My?SQL\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

?????文件????????518??2020-03-14?19:26??My?SQL\My?SQL\Program.cs

?????文件???????1320??2020-03-14?19:26??My?SQL\My?SQL\Properties\AssemblyInfo.cs

?????文件???????2825??2020-03-14?19:26??My?SQL\My?SQL\Properties\Resources.Designer.cs

?????文件???????5612??2020-03-14?19:26??My?SQL\My?SQL\Properties\Resources.resx

............此處省略18個(gè)文件信息

評(píng)論

共有 條評(píng)論

相關(guān)資源