本文整理汇总了C#中System.Data.OleDb.OleDbDataAdapter类的典型用法代码示例。如果您正苦于以下问题:C# System.Data.OleDb.OleDbDataAdapter类的具体用法?C# System.Data.OleDb.OleDbDataAdapter怎么用?C# System.Data.OleDb.OleDbDataAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Data.OleDb.OleDbDataAdapter类属于命名空间,在下文中一共展示了System.Data.OleDb.OleDbDataAdapter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddEvent
public int AddEvent(String eventName, String eventRoom,
String eventAttendees, String eventDate)
{
System.Data.OleDb.OleDbConnection oleDbConnection1;
System.Data.OleDb.OleDbDataAdapter daEvents;
DataSet ds;
oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\\Inetpub\\wwwroot\\PCSWebApp3\\PCSWebApp3.mdb";
String oleDbCommand = "INSERT INTO Events (Name, Room, AttendeeList," +
" EventDate) VALUES ('" + eventName + "', '" +
eventRoom + "', '" + eventAttendees + "', '" +
eventDate + "')";
System.Data.OleDb.OleDbCommand insertCommand =
new System.Data.OleDb.OleDbCommand(oleDbCommand,
oleDbConnection1);
oleDbConnection1.Open();
int queryResult = insertCommand.ExecuteNonQuery();
if (queryResult == 1)
{
daEvents = new System.Data.OleDb.OleDbDataAdapter(
"SELECT * FROM Events", oleDbConnection1);
ds = (DataSet)Application["ds"];
ds.Tables["Events"].Clear();
daEvents.Fill(ds, "Events");
Application.Lock();
Application["ds"] = ds;
Application.UnLock();
oleDbConnection1.Close();
}
return queryResult;
}
开发者ID:alannet,项目名称:example,代码行数:33,代码来源:Service1.asmx.cs
示例2: SelectToDataTable
public DataTable SelectToDataTable(string sql)
{
//set connection
System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection();
con.ConnectionString = connectString;
//set commandtext
System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand();
command.CommandText = sql;
command.Connection = con;
//set adapter
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter();
adapter.SelectCommand = command;
//creat a datatable
DataTable dt = new DataTable();
try
{
//open this connection
con.Open();
adapter.Fill(dt);
}
catch (Exception ex)
{
//throw new Exception
con.Close();
}
finally
{
//close this connection
con.Close();
}
//return a datatable
return dt;
}
开发者ID:CtripHackthon,项目名称:TravelOnline,代码行数:33,代码来源:ExcelOperate.cs
示例3: InitializeComponent
/// <summary>
/// M�todo necesario para admitir el Dise�ador, no se puede modificar
/// el contenido del m�todo con el editor de c�digo.
/// </summary>
private void InitializeComponent()
{
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
this.dsFicha1 = new ficha_antecedentes_personales.dsFicha();
((System.ComponentModel.ISupportInitialize)(this.dsFicha1)).BeginInit();
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = "Provider=SQLOLEDB;server=edoras;OLE DB Services = -2;uid=protic;pwd=,.protic;init" +
"ial catalog=protic2";
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = @"select '' as nombre, '' as rut, '' as pasaporte, '' as fecha_nac, '' as fono, '' as nacionalidad, '' as Estado_civil, '' as Direccion, '' as comuna, '' as ciudad, '' as region, '' as colegio_egreso, '' as ano_egreso, '' as proced_educ, '' as inst_educ_sup, '' as Carrera, '' as ano_ingr, '' as FinanciaEst, '' as ultimo_post_ncorr, '' as nombre_sost_ec, '' as RUT_sost_ec, '' as fnac_sost_ec, '' as edad_sost, '' as fono_sost_ec, '' as pare_sost_ec, '' as dire_tdesc_sost_ec, '' as comu_sost_ec, '' as ciud_sost_ec, '' as regi_sost_ec";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
//
// oleDbDataAdapter1
//
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
//
// dsFicha1
//
this.dsFicha1.DataSetName = "dsFicha";
this.dsFicha1.Locale = new System.Globalization.CultureInfo("es-CL");
this.dsFicha1.Namespace = "http://www.tempuri.org/dsFicha.xsd";
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.dsFicha1)).EndInit();
}
开发者ID:yesashii,项目名称:upa,代码行数:34,代码来源:Ficha.aspx.cs
示例4: Application_Start
protected void Application_Start(Object sender, EventArgs e)
{
System.Data.DataSet ds;
System.Data.OleDb.OleDbConnection oleDbConnection1;
System.Data.OleDb.OleDbDataAdapter daAttendees;
System.Data.OleDb.OleDbDataAdapter daRooms;
System.Data.OleDb.OleDbDataAdapter daEvents;
oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
oleDbConnection1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Inetpub\wwwroot\PCSWebApp3\PCSWebApp3.mdb;Mode=ReadWrite|Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
oleDbConnection1.Open();
ds = new DataSet();
daAttendees = new System.Data.OleDb.OleDbDataAdapter(
"SELECT * FROM Attendees", oleDbConnection1);
daRooms = new System.Data.OleDb.OleDbDataAdapter(
"SELECT * FROM Rooms", oleDbConnection1);
daEvents = new System.Data.OleDb.OleDbDataAdapter(
"SELECT * FROM Events", oleDbConnection1);
daAttendees.Fill(ds, "Attendees");
daRooms.Fill(ds, "Rooms");
daEvents.Fill(ds, "Events");
oleDbConnection1.Close();
Application["ds"] = ds;
}
开发者ID:alannet,项目名称:example,代码行数:26,代码来源:Global.asax.cs
示例5: DBSetup
public void DBSetup()
{
// +++++++++++++++++++++++++++ DBSetup function +++++++++++++++++++++++++++
// This DBSetup() method instantiates all the DB objects needed to access a DB,
// including OleDbDataAdapter, which contains 4 other objects(OlsDbSelectCommand,
// oleDbInsertCommand, oleDbUpdateCommand, oleDbDeleteCommand.) And each
// Command object contains a Connection object and an SQL string object.
OleDbDataAdapter2 = new System.Data.OleDb.OleDbDataAdapter();
OleDbSelectCommand2 = new System.Data.OleDb.OleDbCommand();
OleDbInsertCommand2 = new System.Data.OleDb.OleDbCommand();
OleDbUpdateCommand2 = new System.Data.OleDb.OleDbCommand();
OleDbDeleteCommand2 = new System.Data.OleDb.OleDbCommand();
OleDbConnection2 = new System.Data.OleDb.OleDbConnection();
OleDbDataAdapter2.DeleteCommand = OleDbDeleteCommand2;
OleDbDataAdapter2.InsertCommand = OleDbInsertCommand2;
OleDbDataAdapter2.SelectCommand = OleDbSelectCommand2;
OleDbDataAdapter2.UpdateCommand = OleDbUpdateCommand2;
// The highlighted text below should be changed to the location of your own database
OleDbConnection2.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Reg" + "istry Path =; Jet OLEDB:Database L" +
"ocking Mode=1;Data Source= C:\\Users\\Trenton MCleod\\Desktop\\RegistrationDB.mdb;J" +
"et OLEDB:Engine Type=5;Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:System datab" +
"ase=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Mode=S" +
"hare Deny None;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet " +
"OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repai" +
"r=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";
} //end DBSetup()
开发者ID:TrentonMcleod,项目名称:Project,代码行数:30,代码来源:Instructor.cs
示例6: GetColumnNames
public System.Collections.Generic.List<string> GetColumnNames(string file, string table)
{
System.Data.DataTable dataSet = new System.Data.DataTable();
string connString = "";
if (Global.filepassword != "")
{
if (Path.GetExtension(file).ToString().ToUpper() != ".ACCDB")
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + file + ";Jet OLEDB:Database Password=" + Global.filepassword;
else
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file + ";Jet OLEDB:Database Password=" + Global.filepassword;
}
else
{
if (Path.GetExtension(file).ToString().ToUpper() != ".ACCDB")
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + file;
else
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file + ";Persist Security Info=False;";
}
using (System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection(connString))
{
connection.Open();
System.Data.OleDb.OleDbCommand Command = new System.Data.OleDb.OleDbCommand("SELECT * FROM " + table, connection);
using (System.Data.OleDb.OleDbDataAdapter dataAdapter = new System.Data.OleDb.OleDbDataAdapter(Command))
{
dataAdapter.Fill(dataSet);
}
}
System.Collections.Generic.List<string> columns = new System.Collections.Generic.List<string>();
for (int i = 0; i < dataSet.Columns.Count; i++)
{
columns.Add(dataSet.Columns[i].ColumnName);
}
return columns;
}
开发者ID:nagamani-relyon,项目名称:Time_andAttendance,代码行数:34,代码来源:frmMdbTableColumnsSelect.cs
示例7: InitializeComponent
/// <summary>
/// M�todo necesario para admitir el Dise�ador, no se puede modificar
/// el contenido del m�todo con el editor de c�digo.
/// </summary>
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.datosInforme1 = new informe_1.datosInforme();
((System.ComponentModel.ISupportInitialize)(this.datosInforme1)).BeginInit();
//
// oleDbDataAdapter1
//
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Table", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("NOMBRE", "NOMBRE")})});
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = "SELECT \'\' AS NOMBRE FROM DUAL";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = ((string)(configurationAppSettings.GetValue("cadenaConexion", typeof(string))));
//
// datosInforme1
//
this.datosInforme1.DataSetName = "datosInforme";
this.datosInforme1.Locale = new System.Globalization.CultureInfo("es-ES");
this.datosInforme1.Namespace = "http://www.tempuri.org/datosInforme.xsd";
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.datosInforme1)).EndInit();
}
开发者ID:yesashii,项目名称:upa,代码行数:37,代码来源:Informe_1.aspx.cs
示例8: CreateDataAdapter
public static IDbDataAdapter CreateDataAdapter(EnumProviders provider)
{
IDbDataAdapter da;
switch (provider)
{
case EnumProviders.SqlServer:
da = new System.Data.SqlClient.SqlDataAdapter();
break;
case EnumProviders.OleDb:
da = new System.Data.OleDb.OleDbDataAdapter();
break;
case EnumProviders.Odbc:
da = new System.Data.Odbc.OdbcDataAdapter();
break;
case EnumProviders.Oracle:
throw new NotImplementedException("Provider not implemented");
break;
default:
da = new System.Data.SqlClient.SqlDataAdapter();
break;
}
return da;
}
开发者ID:btebaldi,项目名称:Common,代码行数:25,代码来源:DataProvider.cs
示例9: ExecuteScalar
public System.Data.DataTable ExecuteScalar(string sql, ADODB.Connection cn2)
{
rs.Open(sql, cn2, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, -1);
System.Data.OleDb.OleDbDataAdapter ol = new System.Data.OleDb.OleDbDataAdapter();
System.Data.DataTable dt = new System.Data.DataTable();
ol.Fill(dt, rs);
rs.Close();
return dt;
}
开发者ID:andyyo88,项目名称:myproject,代码行数:9,代码来源:connection.cs
示例10: GetDataTableExcel
public static DataTable GetDataTableExcel(string strFileName, string Table)
{
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + strFileName + "; Extended Properties = \"Excel 8.0;HDR=Yes;IMEX=1\";");
conn.Open();
string strQuery = "SELECT * FROM [" + Table + "]";
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(strQuery, conn);
System.Data.DataSet ds = new System.Data.DataSet();
adapter.Fill(ds);
return ds.Tables[0];
}
开发者ID:seapeakhust,项目名称:TestGit2,代码行数:10,代码来源:InputForm1.cs
示例11: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
var dt2 = new DataTable();
System.Data.OleDb.OleDbDataAdapter ol = new System.Data.OleDb.OleDbDataAdapter();
System.Data.DataTable dt = new System.Data.DataTable();
ol.Fill(dt2, product.selectTest2(test.cn));
gvProduct.DataSource = dt2;
gvProduct.DataBind();
}
开发者ID:rudisetiawan88,项目名称:myproject,代码行数:10,代码来源:Default.aspx.cs
示例12: m_select
private void m_select()
{
this.oDS = new DataSet();
this.rq_sql = "SELECT * FROM TB_PERSONNE;"; //Requête SELECT Paramétrée
this.oCMD = new System.Data.OleDb.OleDbCommand(this.rq_sql, this.oCNX); //Création d'un objet commande qui prend en paramètre la requête SQL et la l'objet de Connexion a la BDD.
this.oDA = new System.Data.OleDb.OleDbDataAdapter(this.oCMD); //Création d'un objet DataAdapter qui prend en paramètre l'objet commande. (DataAdapter et l'interface réel entre l'application et la BDD.
this.oDA.Fill(this.oDS, "personne"); //Execution de la requête SQL, si retournes des enregistrements, elle sont placé dans l'objet DataSet, dans la DataTable "Personne".
this.dataGridView1.DataSource = this.oDS; //On attribue le modèle de mon DataSet au gridview pour afficher mes enregistrement.
this.dataGridView1.DataMember = "personne"; //Mais bien définir la table a afficher, car le DataSet peut en contenir plusieur.
}
开发者ID:OrageDev,项目名称:TestApp,代码行数:10,代码来源:Form1.cs
示例13: GetSheetDataForInsert
public DataTable GetSheetDataForInsert(string qrySecondPart)
{
var conn = new System.Data.OleDb.OleDbConnection(
String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';", _path));
DataSet ds = new DataSet();
var adapter = new System.Data.OleDb.OleDbDataAdapter(
qrySecondPart, conn);
adapter.Fill(ds);
return ds.Tables[0];
}
开发者ID:florianika,项目名称:pxwe-data-loader,代码行数:12,代码来源:ExcelFileWrapper.cs
示例14: Method1
public DataSet Method1()
{
string s = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Northwind1.mdb") + ";Persist Security Info=False";
string z = "select * from Клиенты";
System.Data.OleDb.OleDbConnection olcon = new System.Data.OleDb.OleDbConnection(s);
System.Data.OleDb.OleDbCommand olcom = new System.Data.OleDb.OleDbCommand(z, olcon);
System.Data.OleDb.OleDbDataAdapter DA = new System.Data.OleDb.OleDbDataAdapter(olcom);
System.Data.DataSet DS = new System.Data.DataSet();
DA.Fill(DS);
return DS;
}
开发者ID:glebfranko,项目名称:franko,代码行数:12,代码来源:WebService1.asmx.cs
示例15: GetDataTable
public static DataTable GetDataTable(string strFileName)
{
ADODB.Connection oConn = new ADODB.Connection();
oConn.Open("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\";", "", "", 0);
string strQuery = "SELECT * FROM [" + System.IO.Path.GetFileName(strFileName) + "]";
ADODB.Recordset rs = new ADODB.Recordset();
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter();
DataTable dt = new DataTable();
rs.Open(strQuery, "Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\";",
ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 1);
adapter.Fill(dt, rs);
return dt;
}
开发者ID:tranquangchau,项目名称:cshap-2008-2013,代码行数:13,代码来源:Form1.cs
示例16: Read
public System.Data.DataTable Read(string filename)
{
var excelDataAdapter = new System.Data.OleDb.OleDbDataAdapter();
_connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + filename + "; Extended Properties = Excel 8.0;";
var excelConn = new System.Data.OleDb.OleDbConnection(_connectionString);
excelConn.Open();
var dtProtocol = new System.Data.DataTable { TableName = "Protocol" };
var excelCommand = new System.Data.OleDb.OleDbCommand("SELECT * FROM [протокол плавки$]", excelConn);
excelDataAdapter.SelectCommand = excelCommand;
excelDataAdapter.Fill(dtProtocol);
excelConn.Close();
return dtProtocol;
}
开发者ID:pulse-computer-consulting,项目名称:NucleusPub,代码行数:13,代码来源:Excel.cs
示例17: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgNotes = new System.Windows.Forms.DataGrid();
this.daJoin = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
((System.ComponentModel.ISupportInitialize)(this.dgNotes)).BeginInit();
this.SuspendLayout();
//
// dgNotes
//
this.dgNotes.DataMember = "";
this.dgNotes.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgNotes.Location = new System.Drawing.Point(16, 16);
this.dgNotes.Name = "dgNotes";
this.dgNotes.Size = new System.Drawing.Size(744, 336);
this.dgNotes.TabIndex = 0;
//
// daJoin
//
this.daJoin.SelectCommand = this.oleDbSelectCommand1;
this.daJoin.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Notes", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("primulatext", "primulatext"),
new System.Data.Common.DataColumnMapping("visitnote", "visitnote"),
new System.Data.Common.DataColumnMapping("noteid", "noteid"),
new System.Data.Common.DataColumnMapping("primula", "primula")})});
this.daJoin.RowUpdated += new System.Data.OleDb.OleDbRowUpdatedEventHandler(this.oleDbDataAdapter1_RowUpdated);
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source=""C:\Documents and Settings\Anders Ruberg\Mina dokument\Visual Studio Projects\RehabLight\bin\Debug\rehab.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False";
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = "SELECT Charges.primulatext, Notes.visitnote, Notes.noteid, Notes.primula FROM (No" +
"tes INNER JOIN Charges ON Charges.chargeid = Notes.chargeid) WHERE (Notes.primul" +
"a = FALSE) AND (Notes.visitnote = TRUE) AND (MID([Notes.visitdatetime], 1, 4) = " +
"\'2007\')";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
//
// FilteredNotes
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(768, 390);
this.Controls.Add(this.dgNotes);
this.Name = "FilteredNotes";
this.Text = "FilteredNotes";
((System.ComponentModel.ISupportInitialize)(this.dgNotes)).EndInit();
this.ResumeLayout(false);
}
开发者ID:andersruberg,项目名称:RehabLight,代码行数:55,代码来源:FilteredNotes.cs
示例18: InitializeComponent
/// <summary>
/// M�todo necesario para admitir el Dise�ador, no se puede modificar
/// el contenido del m�todo con el editor de c�digo.
/// </summary>
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.contrato1 = new reporte_contrato.contrato();
((System.ComponentModel.ISupportInitialize)(this.contrato1)).BeginInit();
//
// oleDbDataAdapter1
//
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "contrato", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("NOMBRE_INSTITUCION", "NOMBRE_INSTITUCION"),
new System.Data.Common.DataColumnMapping("RUT_INSTITUCION", "RUT_INSTITUCION"),
new System.Data.Common.DataColumnMapping("RUT_POSTULANTE", "RUT_POSTULANTE"),
new System.Data.Common.DataColumnMapping("EDAD", "EDAD"),
new System.Data.Common.DataColumnMapping("NOMBRE_ALUMNO", "NOMBRE_ALUMNO"),
new System.Data.Common.DataColumnMapping("CARRERA", "CARRERA"),
new System.Data.Common.DataColumnMapping("RUT_CODEUDOR", "RUT_CODEUDOR"),
new System.Data.Common.DataColumnMapping("NOMBRE_CODEUDOR", "NOMBRE_CODEUDOR"),
new System.Data.Common.DataColumnMapping("DIRECCION", "DIRECCION"),
new System.Data.Common.DataColumnMapping("CIUDAD", "CIUDAD"),
new System.Data.Common.DataColumnMapping("COMUNA", "COMUNA"),
new System.Data.Common.DataColumnMapping("TIPO_DOCUMENTO", "TIPO_DOCUMENTO"),
new System.Data.Common.DataColumnMapping("DOCUMENTO", "DOCUMENTO"),
new System.Data.Common.DataColumnMapping("NOMBRE_BANCO", "NOMBRE_BANCO"),
new System.Data.Common.DataColumnMapping("VALOR_DOCTO", "VALOR_DOCTO"),
new System.Data.Common.DataColumnMapping("FECHA_VENCIMIENTO", "FECHA_VENCIMIENTO"),
new System.Data.Common.DataColumnMapping("TOTAL_M", "TOTAL_M"),
new System.Data.Common.DataColumnMapping("TOTAL_A", "TOTAL_A")})});
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = @"SELECT '' AS NOMBRE_INSTITUCION, '' AS RUT_INSTITUCION, '' AS RUT_POSTULANTE, '' AS EDAD, '' AS NOMBRE_ALUMNO, '' AS CARRERA, '' AS RUT_CODEUDOR, '' AS NOMBRE_CODEUDOR, '' AS DIRECCION, '' AS CIUDAD, '' AS COMUNA, '' AS TIPO_DOCUMENTO, '' AS DOCUMENTO, '' AS NOMBRE_BANCO, '' AS VALOR_DOCTO, '' AS FECHA_VENCIMIENTO, '' AS TOTAL_M, '' AS TOTAL_A FROM DUAL";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = ((string)(configurationAppSettings.GetValue("cadenaConexion", typeof(string))));
//
// contrato1
//
this.contrato1.DataSetName = "contrato";
this.contrato1.Locale = new System.Globalization.CultureInfo("es-ES");
this.contrato1.Namespace = "http://www.tempuri.org/contrato.xsd";
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.contrato1)).EndInit();
}
开发者ID:yesashii,项目名称:upa,代码行数:54,代码来源:imprimir_contrato.aspx.cs
示例19: GetDataTableFromCSV
public static DataTable GetDataTableFromCSV(string strFileName)
{
try
{
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + System.IO.Path.GetDirectoryName(strFileName) + "; Extended Properties = \"Text;HDR=YES;FMT=Delimited\"");
conn.Open();
string strQuery = "Select * from [" + System.IO.Path.GetFileName(strFileName) + "]";
System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(strQuery, conn);
System.Data.DataSet ds = new System.Data.DataSet();
da.Fill(ds);
return ds.Tables[0];
}
catch (Exception ex) { }
return new DataTable();
}
开发者ID:hcilab-um,项目名称:STColorCorrection,代码行数:15,代码来源:CSV.cs
示例20: ConvertExcelToCsv
public void ConvertExcelToCsv(int worksheetNumber = 1)
{
if (!System.IO.File.Exists(excelFilePath)) throw new FileNotFoundException(excelFilePath);
if (File.Exists(csvOutputFile)) throw new ArgumentException("File exists: " + csvOutputFile);
// connection string
var cnnStr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;IMEX=1;HDR=NO\"", excelFilePath);
var cnn = new System.Data.OleDb.OleDbConnection(cnnStr);
// get schema, then data
var dt = new DataTable();
try
{
cnn.Open();
var schemaTable = cnn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
if (schemaTable.Rows.Count < worksheetNumber) throw new ArgumentException("The worksheet number provided cannot be found in the spreadsheet");
string worksheet = schemaTable.Rows[worksheetNumber - 1]["table_name"].ToString().Replace("'", "");
string sql = String.Format("select * from [{0}]", worksheet);
var da = new System.Data.OleDb.OleDbDataAdapter(sql, cnn);
da.Fill(dt);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
throw e;
}
finally
{
// free resources
cnn.Close();
}
// write out CSV data
using (var wtr = new StreamWriter(csvOutputFile))
{
foreach (DataRow row in dt.Rows)
{
bool firstLine = true;
foreach (DataColumn col in dt.Columns)
{
if (!firstLine) { wtr.Write(","); } else { firstLine = false; }
var data = row[col.ColumnName].ToString().Replace("\"", "\"\"");
wtr.Write(String.Format("\"{0}\"", data));
}
wtr.WriteLine();
}
}
}
开发者ID:alex-rogers-876,项目名称:C-Sharp-Excel-Conversion-Emails,代码行数:48,代码来源:ConvertExceltoCsv.cs
注:本文中的System.Data.OleDb.OleDbDataAdapter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论