示例#1
0
 private DataSet selectStored(DataBaseEngine database, string StoredProcedureName, Parameter Add, out ArrayList Output)
 {
     if (database.TryConnectiongToServer())
     {
         Output = new ArrayList();
         SqlConnection  con = new SqlConnection();
         SqlCommand     cmd = new SqlCommand();
         SqlDataAdapter adp = new SqlDataAdapter();
         DataSet        ds  = new DataSet();
         con.ConnectionString = database.ConnectionString;
         cmd.Connection       = con;
         cmd.CommandText      = StoredProcedureName;
         cmd.CommandType      = CommandType.StoredProcedure;
         int Total = Add.Total;
         int Out   = Add.Output;
         if (Total != 0)
         {
             for (int i = 0; i < Add.Total; i++)
             {
                 cmd.Parameters.Add((string)Add.Parameters[Total * 4 - 4], (SqlDbType)Add.Parameters[Total * 4 - 3], (int)Add.Parameters[Total * 4 - 2]);
                 cmd.Parameters[(string)Add.Parameters[Total * 4 - 4]].Value = (string)Add.Parameters[Total * 4 - 1];
                 Total--;
             }
         }
         if (Out != 0)
         {
             for (int i = 0; i < Add.Output; i++)
             {
                 cmd.Parameters.Add(new SqlParameter(
                                        (string)Add.Parameters[(Add.Total + Out) * 4 - 4],
                                        (SqlDbType)Add.Parameters[(Add.Total + Out) * 4 - 3],
                                        (int)Add.Parameters[(Add.Total + Out) * 4 - 2])).Direction =
                     (ParameterDirection)Add.Parameters[(Add.Total + Out) * 4 - 1];
                 Out--;
             }
         }
         adp.SelectCommand = cmd;
         adp.Fill(ds);
         Out = Add.Output;
         for (int i = 0; i < Add.Output; i++)
         {
             Output.Add(cmd.Parameters[(string)Add.Parameters[(Add.Total + Out) * 4 - 4]].Value);
             Out--;
         }
         return(ds);
     }
     else
     {
         Output = null;
         return(null);
     }
 }
示例#2
0
 private DataSet select(DataBaseEngine database, string selectStatement, SqlDbType[] Types, int[] size, string[] Values)
 {
     if (database.TryConnectiongToServer())
     {
         DataSet       ds  = new DataSet();
         SqlConnection con = new SqlConnection(database.ConnectionString);
         SqlCommand    cmd = new SqlCommand(selectStatement, con);
         AddParameter(CountChar(selectStatement), selectStatement, cmd, Types, size, Values);
         SqlDataAdapter adp = new SqlDataAdapter(cmd);
         adp.Fill(ds);
         return(ds);
     }
     else
     {
         return(null);
     }
 }
示例#3
0
 public DataSet insertClass(DataBaseEngine database, string insertStatement, Parameter Add, DataSet Old)
 {
     if (database.TryConnectiongToServer())
     {
         DataSet       ds = new DataSet(); SqlDataAdapter dp;
         SqlConnection con = new SqlConnection(database.ConnectionString);
         SqlCommand    cmd = new SqlCommand(insertStatement, con);
         ds = addParameterClass(CountChar(insertStatement), insertStatement, cmd, Add, Old);
         dp = new SqlDataAdapter();
         dp.InsertCommand = cmd;
         dp.Update(ds.Tables[0]);
         return(ds);
     }
     else
     {
         return(null);
     }
 }
示例#4
0
 private DataSet selectClass(DataBaseEngine database, string selectStatement, Parameter Add)
 {
     if (database.TryConnectiongToServer())
     {
         DataSet       ds  = new DataSet();
         SqlConnection con = new SqlConnection(database.ConnectionString);
         SqlCommand    cmd = new SqlCommand(selectStatement, con);
         int           num = CountChar(selectStatement);
         if (num != 0)
         {
             AddParameterClass(num, selectStatement, cmd, Add);
         }
         SqlDataAdapter adp = new SqlDataAdapter(cmd);
         adp.Fill(ds);
         return(ds);
     }
     else
     {
         return(null);
     }
 }
示例#5
0
文件: xml.cs 项目: ahmedfahim/PMMS
 public void WriteXml(DataBaseEngine DataBase, string TableName, string XmlName, string SchemaName)
 {
     if (DataBase.TryConnectiongToServer())
     {
         DataSet        ds  = new DataSet();
         SqlConnection  con = new SqlConnection(DataBase.ConnectionString);
         SqlCommand     cmd = new SqlCommand("select " + TableName + ".* from " + TableName, con);
         SqlDataAdapter dep = new SqlDataAdapter(cmd);
         dep.Fill(ds);
         if (SchemaName == null)
         {
             ds.WriteXml(XmlName);
         }
         else if (XmlName == null)
         {
             ds.WriteXmlSchema(SchemaName);
         }
         else
         {
             ds.WriteXml(XmlName);
             ds.WriteXmlSchema(SchemaName);
         }
     }
 }