C 自選字段條件報表

2021-07-10 02:31:06 字數 2083 閱讀 1327

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.sqlclient;

namespace findoperator

private void frm_main_load(object sender, eventargs e)

private void btn_select_click(object sender, eventargs e)

///

/// 查詢資料表中欄位資訊

///

/// 方法返回datatable物件

private listgetfield(string tablename)

' and a.id=c.id",

tablename);

sqldataadapter p_sqldataadapter = new sqldataadapter(//建立資料介面卡

p_str_sqlstr, p_str_connectionstr);

datatable p_dt = new datatable();//建立資料表

p_sqldataadapter.fill(p_dt);//填充資料表

listp_list_studentfield = new list();

for (int i = 0; i < p_dt.rows.count; i++));}

return p_list_studentfield;//返回資料表

}///

/// 動態生成sql語句

///

/// 表名

/// 欄位名

/// 操作符

/// 條件

/// 方法返回sql語句

private string sqlgenerator(string table,string field,string operator,string condition)

like '%%'",field,condition);//新增字串

break;

case "like%":

p_str += string.format(" where like '%'", field, condition);//新增字串

break;

case "%like":

p_str += string.format(" where like '%'", field, condition);//新增字串

break;

default:

if (condition==string.empty)

is null or =''", field);//新增字串

break;

}p_str += string.format(" where ''",//新增字串

field, operator, condition);

break;

}return p_str;//方法返回字串物件

}///

/// 根據指定sql語句查詢資料庫資訊

///

/// 方法返回datatable物件

private datatable getstudent(string sql)

///

/// 查詢資料庫資訊

///

/// 方法返回datatable物件

private datatable getmessage()

class studentfield

//定義屬性

public override string tostring()//重寫tostring方法}}

mysql 單選字段 mysql欄位型別

學習自 感謝原博主的奉獻 mysql支援多種型別,大致可以分為三類 數值 字串 日期 時間。數值型別 型別大小範圍 有符號 範圍 無符號 用途 tinyint1位元組 128,127 0,255 小整數值 smallint2位元組 32768,32768 0,65535 大整數值 mediumin3...

Dynamics 365 多選字段

update tablebase set field 1,對應選項值多個逗號隔開,1 獲取多選框所有選項 public dictionarygetmoreoptionset string entityname,string fieldname,iorganizationservice service...

java poi 匯出execl動態可選字段

在網上看了很多poi動態匯出可選字段的文章,覺得都過於複雜。這裡給出乙個簡單的實現,希望能幫助需要的朋友。需求說明 首先在匯出頁面選擇查詢條件和匯出字段傳到後台,後台根據查詢條件查詢資料,再把資料轉換成匯出字段生成 execl。這裡使用的持久化框架是mybatis,資料跟字段之間的轉換就是通過myb...