C 運算元據庫表和資料庫

2022-05-08 15:36:11 字數 1165 閱讀 9366

<1>c#建立資料庫表:

private void creattable(string name)      //建立資料庫源資料表,name為表名

<2>c# 更新資料庫表

con = new sqlconnection(s);

con.open();

string sqlstr = "update 系統引數 set 內容='" + content + "' where 型別='" + type + "'" + "and 名稱='" + name + "'"; ;   //單引號,然後是雙引號

cmd = new sqlcommand(sqlstr, con);

cmd.executenonquery();

con.close();

<3>c#建立資料庫**

string connectionstr = "data source=a3135;initial catalog=;integrated security=true";

string sqlstr = "select count(*) from sys.databases where name='病歷管理系統資料庫'";

sqlconnection con = new sqlconnection();

con.connectionstring = connectionstr;

con.open();

sqlcommand cmd = new sqlcommand(sqlstr, con);   //判斷當前資料庫是否存在

int flag = int.parse(cmd.executescalar().tostring()); //flag>0則存在,flag<=0則不存在

con.close();

if (flag <= 0)

<4>c# 查詢字串是否含有str字元

sqlstr += " select * from tablename where 姓名 like '%" + str + "%'";

<5>c# 獲取本機區域網內所有資料庫的名字:

private listgetsqlservername()

else

serverlist.add(array);

}serverlist.sort();

return serverlist;

}

運算元據庫 表

1 連線到mysql伺服器 mysql u使用者名稱 p2 檢視全部資料庫 show databases 3 選擇要操作的資料庫 use 資料庫名稱 4 檢視某個資料庫的所有表 show tables 運算元據庫 建立資料庫 create database 資料庫名稱 刪除資料庫 drop data...

MySql 1 運算元據庫和資料表

1 數值 型別用途 說明tinyint 十分小的資料 1個位元組 smallint 較小的資料 2個位元組 mediumint 中等大小的資料 3個位元組 int 常用 標準的整數4個位元組 bigint 較大的資料 8個位元組 float 浮點數4個位元組 double 浮點數8個位元組 deci...

MySQL(一)基礎 運算元據庫和資料表

mysql是乙個關係型資料庫管理系統,是目前最好的 rdbms relational database management system,關聯式資料庫管理系統 應用軟體之一。優點 開源的資料庫軟體,關鍵是免費的!體積小,速度快,總體擁有成本低,招人成本比較低。一般中小型 的開發都選擇 mysql ...