![]() | LANGUAGE | スカ友 | 俺、関東の国王だけど |
SQLライブラリ |
---|
SQLのライブラリです。これでデータベースのアクセスが使いやすくなります。
この記事は 2019年5月15日 水 4:31 に作者によって編集されましたusing System; using System.Collections.Generic; using System.Web; using System.Data.Odbc; using System.Text; public class SqlParam { public OdbcType Type; public object Value; private SqlParam() { } public SqlParam(OdbcType type, object value) { Type = type; Value = value; } public static SqlCmd operator +(SqlParam a, SqlParam b) { return (SqlCmd)a + b; } public static SqlCmd operator +(SqlParam a, string b) { return (SqlCmd)a + b; } public static SqlCmd operator +(SqlParam a, char b) { return (SqlCmd)a + b; } public static SqlCmd operator +(string a, SqlParam b) { return (SqlCmd)a + b; } public static SqlCmd operator +(char a, SqlParam b) { return (SqlCmd)a + b; } } public class SqlCmd { private List<object> Cmd = new List<object>(); private SqlCmd() { } public static implicit operator SqlCmd(string x) { if (x == null) return null; SqlCmd ret = new SqlCmd(); ret.Cmd.Add(x); return ret; } public static implicit operator SqlCmd(char x) { SqlCmd ret = new SqlCmd(); ret.Cmd.Add(x); return ret; } public static implicit operator SqlCmd(SqlParam x) { if (x == null) return null; SqlCmd ret = new SqlCmd(); ret.Cmd.Add(x); return ret; } public static SqlCmd operator +(SqlCmd a, SqlCmd b) { if (a == null) return b; if (b == null) return a; SqlCmd ret = new SqlCmd(); ret.Cmd.AddRange(a.Cmd); ret.Cmd.AddRange(b.Cmd); return ret; } public OdbcCommand SetCommand(OdbcCommand cmd) { cmd.CommandText = TakakuG.For(0, Cmd.Count - 1, new StringBuilder(), (sum, i) => { if (Cmd[i] is string || Cmd[i] is char) return sum.Append(Cmd[i]); else if (Cmd[i] is SqlParam) return sum.Append('?'); else throw new Exception(); }).ToString(); cmd.Parameters.Clear(); foreach (object i in Cmd) if (i is SqlParam) cmd.Parameters.Add("", ((SqlParam)i).Type).Value = ((SqlParam)i).Value; return cmd; } public void ExecNQ(OdbcConnection conn) { SetCommand(conn.CreateCommand()).ExecuteNonQuery(); } public object ExecS(OdbcConnection conn) { return SetCommand(conn.CreateCommand()).ExecuteScalar(); } public OdbcDataReader ExecR(OdbcConnection conn) { return SetCommand(conn.CreateCommand()).ExecuteReader(); } } |
up
|
up
|
SQLライブラリ - アルファ・ラボ|学術掲示板群
[url=http://www.g59s9602tvjh17q962547dhceg2wz8ucs.org/]uedeylyrbbh[/url] <a href="http://www.g59s9602tvjh17q962547dhceg2wz8ucs.org/">aedeylyrbbh</a> edeylyrbbh http://www.g59s9602tvjh17q962547dhceg2wz8ucs.org/ |
<a href="https://www.lasertell.com/808nm-diode-laser-hair-removal-beauty-machine/">808nm Diode Laser Hair Removal Beauty Machine</a>
<a href="https://www.zhu555.com/article-a270606.html">A213B71WBD</a> |
<a href="https://www.fionamargophotography.com/">高品質ディオールブレスレットコピー</a>
<a href="https://www.chinaeryu.com/suitcase/">Suitcase</a> |
<a href="https://www.aopcctv.com/1080p-dvr/">China 1080p Dvr</a>
<a href="https://www.zhu555.com/article-a269793.html">オメガスピードマスタースーパーコピー</a> |
<a href="https://www.gspack.cn/plastic-shrink-wrap/">Plastic Shrink Wrap</a>
<a href="https://www.zhu555.com/article-a276159.html">エルメス財布コピー</a> |
ヒント: 王・農・工・士・商 |