mysql C# reader
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace mySQLReader
{
class Program
{
static void Main(string[] args)
{
string constr = "server=localhost;User Id=root;password=root;Database=users";
MySqlConnection mycon = new MySqlConnection(constr);
try
{
mycon.Open();
string sltStr = "select id, name from user";
string sltResult = "";
int i = 1;
MySqlCommand sqlcmd = new MySqlCommand(sltStr, mycon);
MySqlDataReader reader = sqlcmd.ExecuteReader();
Console.WriteLine("基本資料查詢結果:");
if (reader.HasRows)
{
while (reader.Read())
{
sltResult += "第" + i + "條記錄:" + reader["id"].ToString() + reader["name"].ToString() + "\n";
i++;
}
Console.WriteLine(sltResult);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
mycon.Close();
Console.WriteLine("資料庫正常關閉");
Console.ReadLine();
}
}
}
相關文章
- Java IO - ReaderJava
- Medical Image Reader
- C# MySQL DataAdapterC#MySqlAPT
- Java IO: Reader And WriterJava
- RSS Reader in PC & iPhoneiPhone
- Java IO: Reader和WriterJava
- C# 使用EntityFramework連線MySqlC#FrameworkMySql
- C#訪問MySql原始版C#MySql
- 從JDK原始碼看ReaderJDK原始碼
- 用newsbeauter收the old reader RSS
- The Last Reader Response——13-17AST
- C#訪問MySQL資料庫C#MySql資料庫
- 第十五章 SqlDataReader reader = comm.ExecuteReader(); while (reader.Read())SQLLDAWhile
- iCHM Reader for Mac(chm閱讀器)Mac
- IO流中的Reader讀操作
- Adobe reader multiple languages pack
- Adobe Acrobat Reader 下載BAT
- Spark Connector Reader 原理與實踐Spark
- Java I/O流InputStream,OutputStream,Reader,WriterJava
- Java I/O 教程(八) Writer和ReaderJava
- Adobe Reader 不再支援 LinuxLinux
- RFID 讀寫器 Reader Writer Cloner
- Blazor Pdf Reader PDF閱讀器 元件 更新Blazor元件
- TNS-12570 TNS:packet reader failureAI
- Oracle Database Concepts 10.2 reader planOracleDatabase
- win10系統fine reader怎麼安裝_win10系統fine reader安裝教程【圖文】Win10
- SharePlex reader missed marker wait for xx but got xxAIGo
- PDF Reader Pro for Mac專業PDF閱讀器Mac
- pdf編輯閱讀器PDF Reader Pro for MacMac
- chm格式檔案閱讀器:iCHM Reader for MacMac
- iCHM Reader for Mac chm格式檔案閱讀器Mac
- DjVu Reader Pro for Mac(好用的閱讀軟體)Mac
- GM Reader Pro for Mac(電子書閱讀器)Mac
- PHP讀取Excel之Spreadsheet_Excel_ReaderPHPExcel
- Adobe Acrobat Reader也能用書籤了BAT
- As a reader --> Diffusion Models for Imperceptible and Transferable Adversarial Attack
- mysql儲存過程及c#呼叫標準版MySql儲存過程C#
- C#連線MySQL8.0資料庫失敗C#MySql資料庫