本文整理汇总了C#中DataSet.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet.Clear方法的具体用法?C# DataSet.Clear怎么用?C# DataSet.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSet
的用法示例。
在下文中一共展示了DataSet.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fill
public virtual int Fill(DataSet.SheetsDataTable dataTable) {
this.Adapter.SelectCommand = this.CommandCollection[0];
if ((this.ClearBeforeFill == true)) {
dataTable.Clear();
}
int returnValue = this.Adapter.Fill(dataTable);
return returnValue;
}
示例2: FillBy
public virtual int FillBy(DataSet.SheetsDataTable dataTable, int SheetID) {
this.Adapter.SelectCommand = this.CommandCollection[1];
this.Adapter.SelectCommand.Parameters[0].Value = ((int)(SheetID));
if ((this.ClearBeforeFill == true)) {
dataTable.Clear();
}
int returnValue = this.Adapter.Fill(dataTable);
return returnValue;
}
示例3: ISO8859_GB2312
//��������ת��
//��ʵ���ǽ�dataset�����ݶ�����xml�ļ���Ȼ�������
public static DataSet ISO8859_GB2312(DataSet ds)
{
#region
string xml;
xml = ds.GetXml();
ds.Clear();
//�����ַ���
System.Text.Encoding iso8859, gb2312;
//iso8859
iso8859 = System.Text.Encoding.GetEncoding("iso8859-1");
//����2312
gb2312 = System.Text.Encoding.GetEncoding("gb2312");
byte[] bt;
bt = iso8859.GetBytes(xml);
xml = gb2312.GetString(bt);
ds.ReadXml(new System.IO.StringReader(xml));
return ds;
#endregion
}
示例4: DataSetClearTest
public void DataSetClearTest()
{
var ds = new DataSet();
DataTable parent = ds.Tables.Add("Parent");
DataTable child = ds.Tables.Add("Child");
parent.Columns.Add("id", typeof(int));
child.Columns.Add("ref_id", typeof(int));
child.Constraints.Add(new ForeignKeyConstraint("fk_constraint", parent.Columns[0], child.Columns[0]));
DataRow dr = parent.NewRow();
dr[0] = 1;
parent.Rows.Add(dr);
dr.AcceptChanges();
dr = child.NewRow();
dr[0] = 1;
child.Rows.Add(dr);
dr.AcceptChanges();
try
{
ds.Clear(); // this should clear all the rows in parent & child tables
}
catch (Exception e)
{
throw (new Exception("Exception should not have been thrown at Clear method" + e.ToString()));
}
Assert.Equal(0, parent.Rows.Count);
Assert.Equal(0, child.Rows.Count);
}
示例5: GetCancels
private void GetCancels()
{
if (CancelFoodRsnBtnList != null)
{
CancelFoodRsnBtnList.RemoveAll();
CancelFoodRsnBtnList = null;
}
CancelFoodRsnBtnList = new CancelFoodRsnButtonList(Panel1, 74, 40, Color.LightBlue, Color.FromArgb(255, 128, 128), 4);
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = rms_var.ConnStr;
try
{
SqlCommand selectCMD = new SqlCommand("SELECT * FROM CancelReason", conn);
selectCMD.CommandTimeout = 30;
SqlDataAdapter dbDA = new SqlDataAdapter();
dbDA.SelectCommand = selectCMD;
conn.Open();
DataSet dbDS = new DataSet();
dbDS.Clear();
dbDA.Fill(dbDS, "t");
for (int i = 0; i <= dbDS.Tables[0].Rows.Count - 1; i++)
{
CancelFoodRsnBtnList.AddNewButton(dbDS.Tables[0].Rows[i]["reason"].ToString());
}
CancelReason = dbDS.Tables[0].Rows[0]["reason"].ToString();
CancelFoodRsnBtnList.SelectItem(0);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
}
}
示例6: ReceiveOperatorInfo
//填充操作员信息 LogOperatorID
public static void ReceiveOperatorInfo(string userid)
{
//根据LogOperator返回雇员信息
opinfo.OpID = userid;
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = ConnStr;
try
{
SqlCommand selectCMD = new SqlCommand("SELECT * FROM Operator where OperatorID='" + userid + "'", conn);
selectCMD.CommandTimeout = 30;
SqlDataAdapter dbDA = new SqlDataAdapter();
dbDA.SelectCommand = selectCMD;
conn.Open();
DataSet dbDS = new DataSet();
dbDA.Fill(dbDS, "t");
//获得 EmployeeID->empno
string empno;
empno = dbDS.Tables[0].Rows[0]["EmpID"].ToString();
opinfo.EmpID = empno;
//根据EmpNo返回EmployeeName 和 Department
selectCMD.Dispose();
selectCMD.Connection = conn;
selectCMD.CommandText = "SELECT * FROM Employee where EmpID='" + empno + "'";
dbDA.SelectCommand = selectCMD;
dbDS.Clear();
dbDA.Fill(dbDS, "t");
opinfo.EmployeeName = dbDS.Tables[0].Rows[0]["name"].ToString();
//返回部门名称
string depno;
depno = dbDS.Tables[0].Rows[0]["depcode"].ToString();
selectCMD.Dispose();
selectCMD.Connection = conn;
selectCMD.CommandText = "SELECT * FROM Department where depcode='" + depno + "'";
dbDA.SelectCommand = selectCMD;
dbDS.Clear();
dbDA.Fill(dbDS, "t");
opinfo.Department = dbDS.Tables[0].Rows[0]["deptname"].ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
}
}
示例7: FacturaA
public void FacturaA(PrintPageEventArgs e, int idFact)
{
DataSet dsRemitoA = new DataSet();
DataSet dsFacturaA = new DataSet();
DataSet dsEmpresa = new DataSet();
DataSet dsCliente = new DataSet();
DataSet dsFacturaCliente = new DataSet();
String detalleFact;
String idcliente;
C.CargarDatos(dsFacturaA, "dsFacturaA", "select max(idfactura) from factura");
String idFact = ((dsFacturaA.Tables[0].Rows[0][0]).ToString());
dsFacturaA.Clear();
C.CargarDatos(dsFacturaA, "dsFacturaA", "select flete,seguro,total from factura where idfactura=" + idFact);
C.CargarDatos(dsRemitoA, "dsRemitoA", "select * from remito where idfactura=" + idFact);
Console.WriteLine("select * from remito where idfactura=" + idFact);
detalleFact = Remito.getInfoRemito(C,dsRemitoA.Tables[0].Rows[0][0].ToString());
String fecha = DateTime.Now.ToShortDateString();
C.CargarDatos(dsEmpresa, "dsEmpresa", "select * from empresa");
String remitente = (dsEmpresa.Tables[0].Rows[0][1].ToString());
String dirRemitente = (dsEmpresa.Tables[0].Rows[0][2].ToString());
String telefonoEmpresa = (dsEmpresa.Tables[0].Rows[0][3].ToString());
String ciudadRemitente = (dsEmpresa.Tables[0].Rows[0][4].ToString());
String cuilRemitente = "";
C.CargarDatos(dsFacturaCliente, "dsFacturaCliente", "select idcliente from factura where idfactura=" + idFact);
idcliente = dsFacturaCliente.Tables[0].Rows[0][0].ToString();
C.CargarDatos(dsCliente,"dsCliente","select nombre,apellido,direccion,CUIL,ciudad from clientes where idcliente=" + idcliente);
String destinatario = (dsCliente.Tables[0].Rows[0][0].ToString()+ " "+dsCliente.Tables[0].Rows[0][1].ToString());
String dirDestinatario = (dsCliente.Tables[0].Rows[0][2].ToString());
String ciudadDestinatario = (dsCliente.Tables[0].Rows[0][4].ToString());
String cuilDestinatario = (dsCliente.Tables[0].Rows[0][3].ToString());
String IVA = (dsRemitoA.Tables[0].Rows[0][11].ToString());
String VD = (dsRemitoA.Tables[0].Rows[0][12].ToString());
String CR = (dsRemitoA.Tables[0].Rows[0][13].ToString());
String condVenta = (dsRemitoA.Tables[0].Rows[0][10].ToString());
DataSet aux = new DataSet();
C.CargarDatos(aux, "aux", "select flete,seguro,total,neto,ivari from factura where idfactura=" + idFact);
String flete = (aux.Tables[0].Rows[0][0].ToString()); ;
String seguro = (aux.Tables[0].Rows[0][1].ToString()); ;
String total = (aux.Tables[0].Rows[0][2].ToString()); ;
String neto = (aux.Tables[0].Rows[0][3].ToString());
String ivari = (aux.Tables[0].Rows[0][4].ToString());
Font font = new Font("Tahoma", 10, FontStyle.Bold);
//Imprime la fecha actual
//Fecha 1100 / 1170 / 1250 - 270
e.Graphics.DrawString(fecha, font, Brushes.Black, PrinterUnitConvert.Convert(1050, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(200, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//Remitente 400 - 550
e.Graphics.DrawString(remitente, font, Brushes.Black, PrinterUnitConvert.Convert(390, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(480, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//Destinatario 1200 - 550
e.Graphics.DrawString(destinatario, font, Brushes.Black, PrinterUnitConvert.Convert(1190, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(480, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//Domicilio 380 - 610
e.Graphics.DrawString(dirRemitente, font, Brushes.Black, PrinterUnitConvert.Convert(370, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(540, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//Domicilio 1160 - 610
e.Graphics.DrawString(dirDestinatario, font, Brushes.Black, PrinterUnitConvert.Convert(1140, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(540, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//Localidad 400 - 670
e.Graphics.DrawString(ciudadRemitente, font, Brushes.Black, PrinterUnitConvert.Convert(390, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(590, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//Localidad 1170 - 670
e.Graphics.DrawString(ciudadDestinatario, font, Brushes.Black, PrinterUnitConvert.Convert(1190, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(590, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//C.U.I.T. 340 - 730
e.Graphics.DrawString(cuilRemitente, font, Brushes.Black, PrinterUnitConvert.Convert(340, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(660, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//C.U.I.T. 1120 - 730
e.Graphics.DrawString(cuilDestinatario, font, Brushes.Black, PrinterUnitConvert.Convert(1110, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(660, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//Cuenta Corriente 910 - 800
e.Graphics.DrawString("x", font, Brushes.Black, PrinterUnitConvert.Convert(820, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(735, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//Flete
//A cobrar 1180 - 1420
e.Graphics.DrawString(flete, font, Brushes.Black, PrinterUnitConvert.Convert(1160, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(1350, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//seguro
//A cobrar 1180 - 1480
e.Graphics.DrawString(seguro, font, Brushes.Black, PrinterUnitConvert.Convert(1160, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display), PrinterUnitConvert.Convert(1410, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
//total
//.........这里部分代码省略.........
示例8: LoadCancelList
//返回取消列表
private void LoadCancelList()
{
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
conn.ConnectionString = rms_var.ConnStr;
try
{
SqlCommand selectCMD = new SqlCommand("SELECT * FROM CancelReason", conn);
selectCMD.CommandTimeout = 30;
SqlDataAdapter dbDA = new SqlDataAdapter();
dbDA.SelectCommand = selectCMD;
conn.Open();
DataSet dbDS = new DataSet();
dbDS.Clear();
dbDA.Fill(dbDS, "CancelReason");
//dgCancelReason.DataSource = Nothing
//dgCancelReason.DataSource = dbDS
//dgCancelReason.DataMember = "CancelReason"
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
}
}
示例9: Clear
public void Clear()
{
var ds = new DataSet();
ds.Tables.Add(DataProvider.CreateParentDataTable());
ds.Tables[0].Rows.Add(new object[] { 9, "", "" });
// Clear
ds.Clear();
Assert.Equal(0, ds.Tables[0].Rows.Count);
}
示例10: Clear_WithNoDataWithConstraint
public void Clear_WithNoDataWithConstraint()
{
// Test dataset with no data and with constraint
var ds = new DataSet();
ds.Tables.Add(DataProvider.CreateParentDataTable());
ds.Tables.Add(DataProvider.CreateChildDataTable());
ds.Tables[0].Rows.Clear();
ds.Tables[1].Rows.Clear();
ds.Tables[0].Constraints.Add("test", ds.Tables[1].Columns[0], ds.Tables[0].Columns[0]);
ds.Clear();
}
示例11: FillByTitleId
public virtual int FillByTitleId(DataSet.CredentialDataTable dataTable, long TitleId) {
this.Adapter.SelectCommand = this.CommandCollection[1];
this.Adapter.SelectCommand.Parameters[0].Value = ((long)(TitleId));
if ((this.ClearBeforeFill == true)) {
dataTable.Clear();
}
int returnValue = this.Adapter.Fill(dataTable);
return returnValue;
}
示例12: FillBySubscriberId
public virtual int FillBySubscriberId(DataSet.TokenDataTable dataTable, long SubscriberId) {
this.Adapter.SelectCommand = this.CommandCollection[2];
this.Adapter.SelectCommand.Parameters[0].Value = ((long)(SubscriberId));
if ((this.ClearBeforeFill == true)) {
dataTable.Clear();
}
int returnValue = this.Adapter.Fill(dataTable);
return returnValue;
}
示例13: FillByBody
public virtual int FillByBody(DataSet.TokenDataTable dataTable, string Body) {
this.Adapter.SelectCommand = this.CommandCollection[1];
if ((Body == null)) {
throw new global::System.ArgumentNullException("Body");
}
else {
this.Adapter.SelectCommand.Parameters[0].Value = ((string)(Body));
}
if ((this.ClearBeforeFill == true)) {
dataTable.Clear();
}
int returnValue = this.Adapter.Fill(dataTable);
return returnValue;
}
示例14: FillByDeviceToken
public virtual int FillByDeviceToken(DataSet.APNsDataTable dataTable, string DeviceToken, long TitleId) {
this.Adapter.SelectCommand = this.CommandCollection[1];
if ((DeviceToken == null)) {
throw new global::System.ArgumentNullException("DeviceToken");
}
else {
this.Adapter.SelectCommand.Parameters[0].Value = ((string)(DeviceToken));
}
this.Adapter.SelectCommand.Parameters[1].Value = ((long)(TitleId));
if ((this.ClearBeforeFill == true)) {
dataTable.Clear();
}
int returnValue = this.Adapter.Fill(dataTable);
return returnValue;
}
示例15: FillByAuthKey
public virtual int FillByAuthKey(DataSet.SubscriberDataTable dataTable, string AuthenticationKey) {
this.Adapter.SelectCommand = this.CommandCollection[1];
if ((AuthenticationKey == null)) {
throw new global::System.ArgumentNullException("AuthenticationKey");
}
else {
this.Adapter.SelectCommand.Parameters[0].Value = ((string)(AuthenticationKey));
}
if ((this.ClearBeforeFill == true)) {
dataTable.Clear();
}
int returnValue = this.Adapter.Fill(dataTable);
return returnValue;
}