动态表的SQL插入方法
来源:互联网 发布:mac拔出u盘 编辑:程序博客网 时间:2024/06/03 23:19
public OracleCommand cmd = null;
public OracleConnection conn = null;
private WriteData LA = new WriteData();
public bool insertValues(string TableName, string[] ColumnName, Type[] ColumnType, object[] ColumnValues)
{
bool flag = false;
try
{
this.conn.Open();
if ((ColumnName.Length == ColumnType.Length) && (ColumnName.Length == ColumnValues.Length))
{
string strCmd = "Insert Into" + TableName + "(";
for (int i = 0; i < ColumnName.Length; i++)
{
strCmd += ColumnName[i] + ",";
}
strCmd = strCmd.Remove(strCmd.Length - 1, 1);
strCmd += ") Values (";
for (int i = 0; i < ColumnType.Length; i++)
{
strCmd += "'" + ColumnValues[i].ToString() + "',";
strCmd += ColumnValues[i].ToString() + ",";
strCmd = strCmd.Remove(strCmd.Length - 1, 1) + ")";
}
cmd = new OracleCommand(strCmd, conn);
if (cmd.ExecuteNonQuery() != 0)
{
flag = true;
}
else
{
flag = false;
}
}
else
{
throw new Exception("Number of Arguments do not match");
}
}
catch (Exception exception)
{
this.LA.WriteLine(exception.Message);
}
finally
{
this.conn.Close();
}
return flag;
}
public OracleConnection conn = null;
private WriteData LA = new WriteData();
public bool insertValues(string TableName, string[] ColumnName, Type[] ColumnType, object[] ColumnValues)
{
bool flag = false;
try
{
this.conn.Open();
if ((ColumnName.Length == ColumnType.Length) && (ColumnName.Length == ColumnValues.Length))
{
string strCmd = "Insert Into" + TableName + "(";
for (int i = 0; i < ColumnName.Length; i++)
{
strCmd += ColumnName[i] + ",";
}
strCmd = strCmd.Remove(strCmd.Length - 1, 1);
strCmd += ") Values (";
for (int i = 0; i < ColumnType.Length; i++)
{
strCmd += "'" + ColumnValues[i].ToString() + "',";
strCmd += ColumnValues[i].ToString() + ",";
strCmd = strCmd.Remove(strCmd.Length - 1, 1) + ")";
}
cmd = new OracleCommand(strCmd, conn);
if (cmd.ExecuteNonQuery() != 0)
{
flag = true;
}
else
{
flag = false;
}
}
else
{
throw new Exception("Number of Arguments do not match");
}
}
catch (Exception exception)
{
this.LA.WriteLine(exception.Message);
}
finally
{
this.conn.Close();
}
return flag;
}
- 动态表的SQL插入方法
- 动态sql插入表
- 动态插入HTML的方法
- sql的另类插入方法
- SQL插入表方法总结
- sql把结果集插入临时表的方法
- SQL 动态排序的方法
- 动态插入节点方法
- SQL语句中插入单引号(')的方法
- sql下三种批量插入数据的方法
- sql插入数据的方法以及效率
- SQL Server 批量插入数据的方法
- 动态的创建表的sql,并把查询的结果插入该表
- Mybatis动态sql批量插入
- mybatis动态插入sql语句
- jquery mobile 动态插入元素的正确渲染方法
- jquery mobile 动态插入元素的正确渲染方法
- jquery mobile 动态插入元素的正确渲染方法
- 为什么要进行傅立叶变换?傅立叶变换究竟有何意义?如何用Matlab实现快速傅立叶变换
- ORACLE执行命令
- WinDbg查看函数内存地址
- ARM汇编语言指令(1)
- Incorrect string value异常——MySQL编码细说
- 动态表的SQL插入方法
- 国家对五险一金的交纳说明,太有用了,找都找不到
- 各位闲着没事就可以随便发些感想啊,quickly
- QT子窗口关闭浅记
- 《LINUX 、UNIX 设计思想》读后感,前六章
- 集成Spring后HibernateTemplate实现分页
- C#给自己写的方法添加注释提示
- Perl语言系列博客:提笔前言
- thoughtworks面试题及解答