当前位置: 首页>>代码示例>>C#>>正文


C# Data.DataSet类代码示例

本文整理汇总了C#中System.Data.DataSet的典型用法代码示例。如果您正苦于以下问题:C# System.Data.DataSet类的具体用法?C# System.Data.DataSet怎么用?C# System.Data.DataSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.Data.DataSet类属于命名空间,在下文中一共展示了System.Data.DataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestStreamDataSet

        private static void TestStreamDataSet()
        {
            //Create a sample DataSet
            System.Data.DataSet ds = new System.Data.DataSet();
            System.Data.DataTable table = ds.Tables.Add("Table1");
            table.Columns.Add("Col1", typeof(string));
            table.Columns.Add("Col2", typeof(double));
            table.Rows.Add("Value 1", 59.7);
            table.Rows.Add("Value 2", 59.9);

            byte[] buffer;

            //Serialize the DataSet (where ds is the dataset)
            using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
            {
                DevAge.Data.StreamDataSet.Write(stream, ds, 
                            DevAge.Data.StreamDataSetFormat.Binary);

                buffer = stream.ToArray();
            }

            //Deserialize the DataSet (where 'buffer' is the previous serialized byte[])
            System.Data.DataSet deserializedDs = new System.Data.DataSet();
            using (System.IO.MemoryStream stream = new System.IO.MemoryStream(buffer))
            {
                DevAge.Data.StreamDataSet.Read(stream, deserializedDs, 
                            DevAge.Data.StreamDataSetFormat.Binary, true);
            }

            System.Diagnostics.Debug.Assert(deserializedDs.Tables[0].Rows.Count == 2);
        }
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:31,代码来源:GenericTest.cs

示例2: DataTableToExcel

 /// <summary>
 /// 导出Excel,以旧列名-新列名词典为标头
 /// </summary>
 /// <param name="dt"></param>
 /// <param name="dicCoumnNameMapping"></param>
 public static void DataTableToExcel(System.Data.DataTable dt, Dictionary<string, string> dicCoumnNameMapping, string fileName)
 {
     ExcelHandler eh = new ExcelHandler();
     SheetExcelForm frm = new SheetExcelForm();
     eh.ProcessHandler = frm.AddProcess;
     eh.ProcessErrorHandler = new Action<string>((msg) =>
     {
         MessageBox.Show(msg);
     });
     try
     {
         frm.Show();
         Delay(20);
         var ds = new System.Data.DataSet();
         ds.Tables.Add(dt);
         eh.DataSet2Excel(ds, dicCoumnNameMapping, fileName);
         ds.Tables.Remove(dt);
         ds.Dispose();
     }
     catch (Exception ex)
     {
         MessageBox.Show("导出Excel错误:" + ex.Message);
     }
     finally
     {
         Delay(20);
         frm.Close();
     }
 }
开发者ID:howbigbobo,项目名称:DailyCode,代码行数:34,代码来源:WinFormExcelExporter.cs

示例3: acquireData

        private void acquireData()
        {
            OdbcConnection conn = new OdbcConnection("Driver={SQL Server Native Client 11.0}; server=jfsql2014;database=d3charting;trusted_connection=yes;");
               OdbcCommand cmd = new OdbcCommand("select * from bar_chart;");

               conn.Open();
               cmd.Connection = conn;

               OdbcDataAdapter da = new OdbcDataAdapter();
               System.Data.DataSet ds = new System.Data.DataSet();
               da.SelectCommand = cmd;
               da.Fill(ds);

               JSONDocument = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None);

               cmd = new OdbcCommand("select T.Product, T.[This Year] as TY, F.Forecast FROM bar_chart T JOIN forecast F ON T.Product = F.Product");
               cmd.Connection = conn;
               da = new OdbcDataAdapter();
               ds = new System.Data.DataSet();
               da.SelectCommand = cmd;
               da.Fill(ds);

               ForecastData = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None);

               conn.Close();
        }
开发者ID:scardella,项目名称:d3charting,代码行数:26,代码来源:barchart.aspx.cs

示例4: TC_SetDislay

        public void TC_SetDislay(System.Data.DataSet ds)
        {
            checkConntected();

              if (ds.Tables[0].Rows[0]["func_name"].ToString() != "set_speed")
              throw new Exception("only support func_name = set_speed");

              lock (this.currDispLockObj)
              {
              if (currDisplayds == null)
              {

                  this.InvokeOutPutChangeEvent(this, ds.Tables[0].Rows[0]["speed"].ToString());
              }
              else
                  if (currDisplayds.Tables[0].Rows[0]["speed"].ToString() != ds.Tables[0].Rows[0]["speed"].ToString())

                      this.InvokeOutPutChangeEvent(this, ds.Tables[0].Rows[0]["speed"].ToString());

                      currDisplayds = ds;
              Comm.SendPackage pkg = this.m_protocol.GetSendPackage(ds, 0xffff);

              this.Send(pkg);

              }
        }
开发者ID:ufjl0683,项目名称:Center,代码行数:26,代码来源:CSLSTC.cs

示例5: LoadData

        private void LoadData()
        {
            taskDataAdapter = new System.Data.SQLite.SQLiteDataAdapter("SELECT * FROM events WHERE ID=" + id, connection);
            alertsDataAdapter = new System.Data.SQLite.SQLiteDataAdapter("SELECT * FROM events_alerts WHERE event_id=" + id, connection);

            dataSet = new System.Data.DataSet();

            var taskCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(taskDataAdapter);
            var alertsCommandBuilder = new System.Data.SQLite.SQLiteCommandBuilder(alertsDataAdapter);

            taskDataAdapter.Fill(dataSet, "event");
            alertsDataAdapter.Fill(dataSet, "alerts");

            var parentColumn = dataSet.Tables["event"].Columns["ID"];

            {
                var childColumn = dataSet.Tables["alerts"].Columns["event_id"];
                var relation = new System.Data.DataRelation("event_alerts", parentColumn, childColumn);
                dataSet.Relations.Add(relation);
            }

            //var table = dataSet.Tables["event"];
            row = dataSet.Tables["event"].Rows[0];
            dataSet.Tables["event"].RowChanged += table_RowChanged;
            dataSet.Tables["alerts"].RowChanged += table_RowChanged;
            dataSet.Tables["alerts"].RowDeleted += table_RowDeleted;
            dataSet.Tables["alerts"].TableNewRow += table_TableNewRow;

            FillDeadline(row);
            FillTags(id);

            TaskGrid.DataContext = dataSet.Tables["event"].DefaultView;
            AlertsDataGrid.ItemsSource = dataSet.Tables["alerts"].DefaultView;
        }
开发者ID:xeph,项目名称:LOG350.TP3,代码行数:34,代码来源:Events.xaml.cs

示例6: consultaInformacion

        //Procedimiento que consulta información definida por  parámetros del
        //query, retorna un dataset con la información
        public System.Data.DataSet consultaInformacion(String queryToExecute)
        {
            String resultadoOperacion;
            System.Data.DataSet sqlDsConsulta = new System.Data.DataSet(); ;
            resultadoOperacion = "EXITOSO";
            abreConexion();
            try
            {
                //Crea las instancias
                this.sqlCmdConsulta = new SqlCommand();
                this.sqlDaConsulta = new SqlDataAdapter();

                //Construye el comando Select
                sqlCmdConsulta.Connection = cnBaseDatos;
                sqlCmdConsulta.CommandText = queryToExecute;
                sqlCmdConsulta.CommandType = System.Data.CommandType.Text;
                sqlDaConsulta.SelectCommand = sqlCmdConsulta;
                //Carga el DataSet
                this.sqlDaConsulta.Fill(sqlDsConsulta);
            }
            catch (SqlException exc)
            {

                //resultadoOperacion = "Error(" & exc.Number.ToString & "): " & exc.Messag;
            }
            return sqlDsConsulta;
        }
开发者ID:dar2608,项目名称:PrograVI,代码行数:29,代码来源:clsConexion.cs

示例7: GetParameter

    private System.Data.DataRow GetParameter(string IDParametro, int? IDPortal, int? IDSistema, string IDUsuario)
    {
      // Aca se lee la informacion de la base de datos
      // y se preparan los layers
      string connStr = ValidacionSeguridad.Instance.GetSecurityConnectionString();
      System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connStr);
      conn.Open();

      System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand
        ("SELECT * FROM dbo.SF_VALOR_PARAMETRO(@IDParametro, @IDPortal, @IDSistema, @IDUsuario)", conn);

      System.Data.SqlClient.SqlParameter prm = new System.Data.SqlClient.SqlParameter("@IDParametro", System.Data.SqlDbType.VarChar, 100);
      prm.Value = IDParametro;
      cmd.Parameters.Add(prm);

      prm = new System.Data.SqlClient.SqlParameter("@IDPortal", System.Data.SqlDbType.Int);
      if (IDPortal.HasValue)
      {
        prm.Value = IDPortal.Value;
      }
      else
      {
        prm.Value = null;
      }
      cmd.Parameters.Add(prm);

      prm = new System.Data.SqlClient.SqlParameter("@IDSistema", System.Data.SqlDbType.Int);
      if (IDSistema.HasValue)
      {
        prm.Value = IDSistema.Value;
      }
      else
      {
        prm.Value = null;
      }
      cmd.Parameters.Add(prm);

      prm = new System.Data.SqlClient.SqlParameter("@IDUsuario", System.Data.SqlDbType.VarChar);
      if (IDUsuario != null)
      {
        prm.Value = IDUsuario;
      }
      else
      {
        prm.Value = null;
      }
      cmd.Parameters.Add(prm);

      //     IdParametro, Alcance, ValorTexto, ValorEntero, ValorDecimal, ValorLogico, ValorFechaHora
      cmd.CommandType = System.Data.CommandType.Text;
      System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd);

      System.Data.DataSet ds = new System.Data.DataSet();
      da.Fill(ds);

      conn.Close();

      return ds.Tables[0].Rows[0];
      //return resultado;
    }
开发者ID:diegowald,项目名称:intellitrack,代码行数:60,代码来源:UDPHandler.cs

示例8: Process

		internal static void Process (List<string> assemblies, string outputPath)
		{
			List<string> valid_config_files = new List<string> ();
			foreach (string assembly in assemblies) {
				string assemblyConfig = assembly + ".config";
				if (File.Exists (assemblyConfig)) {
					XmlDocument doc = new XmlDocument ();
					try {
						doc.Load (assemblyConfig);
					} catch (XmlException) {
						doc = null;
					}
					if (doc != null)
						valid_config_files.Add (assemblyConfig);
				}
			}
			
			if (valid_config_files.Count == 0)
				return;

			string first_file = valid_config_files [0];
			System.Data.DataSet dataset = new System.Data.DataSet ();
			dataset.ReadXml (first_file);
			valid_config_files.Remove (first_file);
			
			foreach (string config_file in valid_config_files) {
				System.Data.DataSet next_dataset = new System.Data.DataSet ();
				next_dataset.ReadXml (config_file);
				dataset.Merge (next_dataset);
			}
			dataset.WriteXml (outputPath + ".config");
		}
开发者ID:transformersprimeabcxyz,项目名称:cecil-old,代码行数:32,代码来源:ConfigMerger.cs

示例9: EmployeeDataSet

 protected EmployeeDataSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : 
         base(info, context, false) {
     if ((this.IsBinarySerialized(info, context) == true)) {
         this.InitVars(false);
         System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler1 = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
         this.Tables.CollectionChanged += schemaChangedHandler1;
         this.Relations.CollectionChanged += schemaChangedHandler1;
         return;
     }
     string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
     if ((this.DetermineSchemaSerializationMode(info, context) == System.Data.SchemaSerializationMode.IncludeSchema)) {
         System.Data.DataSet ds = new System.Data.DataSet();
         ds.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema)));
         if ((ds.Tables["employee"] != null)) {
             base.Tables.Add(new employeeDataTable(ds.Tables["employee"]));
         }
         this.DataSetName = ds.DataSetName;
         this.Prefix = ds.Prefix;
         this.Namespace = ds.Namespace;
         this.Locale = ds.Locale;
         this.CaseSensitive = ds.CaseSensitive;
         this.EnforceConstraints = ds.EnforceConstraints;
         this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
         this.InitVars();
     }
     else {
         this.ReadXmlSchema(new System.Xml.XmlTextReader(new System.IO.StringReader(strSchema)));
     }
     this.GetSerializationData(info, context);
     System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
     base.Tables.CollectionChanged += schemaChangedHandler;
     this.Relations.CollectionChanged += schemaChangedHandler;
 }
开发者ID:antklim,项目名称:consumables,代码行数:33,代码来源:EmployeeDataSet.Designer.cs

示例10: listar

        public List<Combustivel> listar()
        {
            List<Combustivel> lista = new List<Combustivel>();
            System.Data.DataSet ds = new System.Data.DataSet();
            Int32 x = 0;

            try
            {
                SqlDataReader reader;
                command.Connection = MsSQL.getConexao();
                command.Connection.Open();
                vsql.Append("SELECT ID, DESCRICAO FROM COMBUSTIVEL ");
                vsql.Append("ORDER BY DESCRICAO ");
                command.CommandText = vsql.ToString();
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    lista.Add(new Combustivel());
                    lista[x].ID = Convert.ToInt32(reader["ID"]);
                    lista[x].Descricao = reader["DESCRICAO"].ToString();
                    x++;
                }
                return lista;
            }
            catch (Exception e)
            {
                throw new Exception("Erro ao montar a lista de Tipo de combustível. " + e.Message);
            }
            finally
            {
                command.Connection.Close();
            }
        }
开发者ID:chmcorbo,项目名称:App.NET,代码行数:33,代码来源:DAOCombustivel.cs

示例11: GetDataBySql

 public static System.Data.DataTable GetDataBySql(string sql)
 {
     SqlConnection con = new SqlConnection(StrCon); con.Open();
     SqlDataAdapter da = new SqlDataAdapter(sql, StrCon); System.Data.DataSet ds = new System.Data.DataSet();
     da.Fill(ds); con.Dispose(); con.Close();
     return ds.Tables[0];
 }
开发者ID:mrk29vn,项目名称:vna-accounting,代码行数:7,代码来源:Connection.cs

示例12: GetAllRecordsFromXML

 public void GetAllRecordsFromXML()
 {
     System.Data.DataSet ds = new System.Data.DataSet();
     ds.ReadXml(Server.MapPath("Login.xml"));
     GridView1.DataSource = ds;
     GridView1.DataBind();
 }
开发者ID:pkgod7,项目名称:windowsphone-sprmalaysia,代码行数:7,代码来源:Login.aspx.cs

示例13: SelectFromXLS

        /// <summary>
        /// 执行查询
        /// </summary>
        /// <param name="ServerFileName">xls文件路径</param>
        /// <param name="SelectSQL">查询SQL语句</param>
        /// <returns>DataSet</returns>
        public static System.Data.DataSet SelectFromXLS(string ServerFileName, string SelectSQL)
        {

            string connStr = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + ServerFileName + "';Extended Properties=Excel 8.0";
            OleDbConnection conn = new OleDbConnection(connStr);
            OleDbDataAdapter da = null;
            System.Data.DataSet ds = new System.Data.DataSet();
            try
            {
                conn.Open();
                da = new OleDbDataAdapter(SelectSQL, conn);
                da.Fill(ds, "SelectResult");
            }
            catch (Exception e)
            {
                conn.Close();
                throw e;
            }
            finally
            {
                conn.Close();
            }
            return ds;

        }
开发者ID:HP-Richard,项目名称:https---github.com-litianbao-GoldenCat,代码行数:31,代码来源:Util_XLS.cs

示例14: TC_SetDislay

        public void TC_SetDislay(System.Data.DataSet ds)
        {
            checkConntected();

              string oldDispStr = "";
              if (ds.Tables[0].Rows[0]["func_name"].ToString() != "set_ctl_sign")
              throw new Exception("only support func_name = set_ctl_sign");

              if (this.currDisplayds == null )

              {
              lock (currDispLockObj)
              currDisplayds = ds;

              Comm.SendPackage pkg = this.m_protocol.GetSendPackage(ds, 0xffff);
              this.Send(pkg);

             this.InvokeOutPutChangeEvent(this, this.GetCurrentDisplayDecs());
              return;
              }
              else
             oldDispStr = this.GetCurrentDisplayDecs();

              lock(currDispLockObj)
              currDisplayds = ds;
              if (oldDispStr != this.GetCurrentDisplayDecs())
              {
              Comm.SendPackage pkg = this.m_protocol.GetSendPackage(ds, 0xffff);
              this.Send(pkg);
              this.InvokeOutPutChangeEvent(this, this.GetCurrentDisplayDecs());
              }
        }
开发者ID:ufjl0683,项目名称:Center,代码行数:32,代码来源:LCSTC.cs

示例15: Demonstrate

        public static void Demonstrate()
        {
            var myInt = 100;
            myInt.DisplayDefiningAssembly();

            var ds = new System.Data.DataSet();
            ds.DisplayDefiningAssembly();
        }
开发者ID:eswise,项目名称:Training,代码行数:8,代码来源:04_ExtensionMethods.cs


注:本文中的System.Data.DataSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。