12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using MySql.Data.MySqlClient;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.OleDb;
- using System.Data.SqlClient;
- using System.Linq;
- namespace BaseLibDataProcess
- {
- public class SQLFunction
- {
- /// <summary>
- /// 获取指定表的指定字段的指定值的插入语句
- /// </summary>
- /// <param name="Table">表</param>
- /// <param name="arrField">字段</param>
- /// <param name="arrValue">值</param>
- /// <returns>字符串值</returns>
- public static string getInsertString(string Function, string Table, string[] arrField, string[] arrValue)
- {
- string strSQL = string.Empty;
- if (arrField.Length != arrValue.Length)
- {
- throw new OraDBBaseException("字段的个数和值的个数不一致");
- }
- string str1 = "", str2 = "";
- strSQL = Function + " into " + Table + "(";
- for (int i = 0; i < arrField.Length; i++)
- {
- str1 += string.Format("{0},", arrField[i]);
- str2 += string.Format("'{0}',", arrValue[i]);
- }
- strSQL += str1.Substring(0, str1.Length - 1) + ") values (";
- strSQL += str2.Substring(0, str2.Length - 1) + ")";
- return strSQL;
- }
- public enum SQLname
- {
- insert,
- update,
- delete
- }
- }
- }
|