本文整理汇总了C#中System.Data.OleDb.OleDbCommand.ExecuteReader方法的典型用法代码示例。如果您正苦于以下问题:C# System.Data.OleDb.OleDbCommand.ExecuteReader方法的具体用法?C# System.Data.OleDb.OleDbCommand.ExecuteReader怎么用?C# System.Data.OleDb.OleDbCommand.ExecuteReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbCommand
的用法示例。
在下文中一共展示了System.Data.OleDb.OleDbCommand.ExecuteReader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: makeAll
public static void makeAll(System.String baseDirectory, System.String version)
{
//make base directory
if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
{
baseDirectory = baseDirectory + "/";
}
System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "EventMapping");
//get list of data types
System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
System.String sql = "SELECT * from HL7EventMessageTypes inner join HL7Versions on HL7EventMessageTypes.version_id = HL7Versions.version_id where HL7Versions.hl7_version = '" + version + "'";
System.Data.OleDb.OleDbCommand temp_OleDbCommand = new System.Data.OleDb.OleDbCommand();
temp_OleDbCommand.Connection = conn;
temp_OleDbCommand.CommandText = sql;
System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
using (StreamWriter sw = new StreamWriter(targetDir.FullName + @"\EventMap.properties", false))
{
sw.WriteLine("#event -> structure map for " + version);
while (rs.Read())
{
string messageType = string.Format("{0}_{1}", rs["message_typ_snd"], rs["event_code"]);
string structure = (string) rs["message_structure_snd"];
sw.WriteLine(string.Format("{0} {1}", messageType, structure));
}
}
}
示例2: button3_Click
private void button3_Click(object sender, EventArgs e)
{ // Botão btnResultados
try
{
string id1 = txtIdade1.Text;
string id2 = txtIdade2.Text;
string strSsexo = "";
if (rbMasculino.Checked) strSsexo = " sexo = 'M' AND ";
else if (rbFeminino.Checked) strSsexo = " sexo = 'F' AND ";
else strSsexo = "";
sql = "select * from alunos WHERE " + strSsexo
+ " idade>=" + id1 + " AND idade<=" + id2
+ " ORDER BY nome";
stm = new System.Data.OleDb.OleDbCommand(sql, conexao);
rs = stm.ExecuteReader();
string strSaida = "";
while (rs.Read())
{
string dados = "RGM: " + rs.GetString(0)
+ ", " + rs.GetString(1) + ", idade: " + rs.GetInt32(3)
+ ", sexo: " + rs.GetString(4)
+ ", curso: " + rs.GetString(2);
strSaida += dados + "\r\n";
}
txtResultados.Text = strSaida;
}
catch (Exception exsql) { MessageBox.Show("Erro na consulta"); }
if(stm!=null)stm.Dispose();
if(rs!=null)rs.Close();
}
示例3: AnalyzeExcel
public static bool AnalyzeExcel(ExcelXMLLayout layout)
{
System.Data.OleDb.OleDbConnection conn = null;
try
{
conn = new System.Data.OleDb.OleDbConnection(MakeConnectionString(layout.solution.path));
conn.Open();
System.Data.DataTable table = conn.GetOleDbSchemaTable(
System.Data.OleDb.OleDbSchemaGuid.Columns,
new object[] { null, null, layout.sheet + "$", null });
layout.Clear();
System.Diagnostics.Debug.WriteLine("Start Analyze [" + table.Rows.Count + "]");
foreach (System.Data.DataRow row in table.Rows)
{
string name = row["Column_Name"].ToString();
System.Diagnostics.Debug.WriteLine(name);
// 测试数据类型
ExcelXMLLayout.KeyType testType = ExcelXMLLayout.KeyType.Unknown;
{
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(
string.Format("select [{0}] from [{1}$]", name, layout.sheet), conn
);
System.Data.OleDb.OleDbDataReader r = cmd.ExecuteReader();
while (r.Read())
{
System.Diagnostics.Debug.WriteLine(r[0].GetType());
if (r[0].GetType() == typeof(System.Double))
{
testType = ExcelXMLLayout.KeyType.Integer;
break;
}
if (testType == ExcelXMLLayout.KeyType.String)
{
break;
}
testType = ExcelXMLLayout.KeyType.String;
}
r.Close();
cmd.Dispose();
}
layout.Add(name, testType);
}
table.Dispose();
conn.Close();
return true;
}
catch (Exception outErr)
{
lastError = string.Format("无法分析,Excel 无法打开\r\n{0}", outErr.Message);
}
return false;
}
示例4: getRowCount
public string getRowCount()
{
string query = "select * from [" + TableName + "]";
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(query, conn);
System.Data.OleDb.OleDbDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dataTable.Load(dr);
dr.Close();
return dataTable.Rows.Count.ToString();
}
示例5: btnGo_Click
protected void btnGo_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
string sql = "";
System.Data.DataSet ds = new System.Data.DataSet();
System.Data.OleDb.OleDbDataReader dr;
System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand();
//http://www.c-sharpcorner.com/UploadFile/dchoksi/transaction02132007020042AM/transaction.aspx
//get this from connectionstrings.com/access
conn.ConnectionString = txtConnString.Text;
conn.Open();
//here I can talk to my db...
System.Data.OleDb.OleDbTransaction Trans;
Trans = conn.BeginTransaction(System.Data.IsolationLevel.Chaos);
try
{
comm.Connection = conn;
comm.Transaction = Trans;
// Trans.Begin();
//Console.WriteLine(conn.State);
sql = txtSQL.Text;
comm.CommandText = sql;
if (sql.ToLower().IndexOf("select") == 0)
{
dr = comm.ExecuteReader();
while (dr.Read())
{
txtresults.Text = dr.GetValue(0).ToString();
}
}
else
{
txtresults.Text = comm.ExecuteNonQuery().ToString();
}
Trans.Commit();
}
catch (Exception ex)
{
txtresults.Text = ex.Message;
Trans.Rollback();
}
finally
{
comm.Dispose();
conn.Close();
conn = null;
}
}
示例6: AttemptReadingDBFWithOLEDB
public void AttemptReadingDBFWithOLEDB()
{
//FeatureLayer target = new MapPolygonLayer();
string filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFiles", "soils.shp");
string dBaseFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFiles");
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source = " + dBaseFile + ";Extended Properties =dBase IV;";
System.Data.OleDb.OleDbConnection dBaseConnection;
dBaseConnection = new System.Data.OleDb.OleDbConnection(connectionString);
dBaseConnection.Open();
System.Data.OleDb.OleDbCommand dBaseCommand;
dBaseCommand = new System.Data.OleDb.OleDbCommand("SELECT * FROM [soils]", dBaseConnection);
System.Data.OleDb.OleDbDataReader dBaseDataReader;
dBaseDataReader = dBaseCommand.ExecuteReader(CommandBehavior.SequentialAccess);
}
示例7: btnGo_Click
private void btnGo_Click(object sender, EventArgs e)
{
lblError.Text = "";
//open connection to database
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
conn.ConnectionString = txtConnString.Text;
conn.Open();
// MessageBox.Show(conn.State.ToString());
//create my command
System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand();
comm.Connection = conn;
//send the sql through the command
comm.CommandText = txtSQL.Text;
//receive the result into a data container.
System.Data.OleDb.OleDbDataReader dr;
try
{
if (txtSQL.Text.ToUpper().StartsWith("SELECT"))
{
dr = comm.ExecuteReader();
System.Data.DataTable dt = new DataTable();
dt.Load(dr);
Grid1.AutoGenerateColumns = true;
//bind the result to the grid
Grid1.DataSource = dt;
}
else
{
MessageBox.Show(comm.ExecuteNonQuery().ToString());
}
}
catch (Exception ex)
{
lblError.Text = ex.Message;
}
finally
{
conn.Close();
}
}
示例8: Main
static void Main(string[] args)
{
string connstring =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DropBox\My Dropbox\Devry\CIS407\SU10B\day5\NorthWind.mdb;";
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
string sql = "";
System.Data.DataSet ds = new System.Data.DataSet();
System.Data.OleDb.OleDbDataReader dr;
System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand();
try
{
//get this from connectionstrings.com/access
conn.ConnectionString = connstring;
conn.Open();
//here I can talk to my db...
comm.Connection = conn;
//Console.WriteLine(conn.State);
sql = Console.ReadLine();
comm.CommandText = sql;
if (sql.ToLower().IndexOf("select") == 0)
{
dr = comm.ExecuteReader();
while (dr.Read())
{
Console.WriteLine(dr.GetString(0));
}
}
else
{
Console.WriteLine(comm.ExecuteNonQuery().ToString());
}
}
catch ( Exception ex)
{
Console.WriteLine(ex.Message);
Console.Read();
}
finally
{
Console.ReadLine();
comm.Dispose();
conn.Close();
conn = null;
}
}
示例9: btnGo_Click
protected void btnGo_Click(object sender, EventArgs e)
{
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
string sql = "";
System.Data.DataSet ds = new System.Data.DataSet();
System.Data.OleDb.OleDbDataReader dr;
System.Data.OleDb.OleDbCommand comm = new System.Data.OleDb.OleDbCommand();
try
{
//get this from connectionstrings.com/access
conn.ConnectionString = txtConnString.Text;
conn.Open();
//here I can talk to my db...
comm.Connection = conn;
//Console.WriteLine(conn.State);
sql = txtSQL.Text;
comm.CommandText = sql;
if (sql.ToLower().IndexOf("select") == 0)
{
dr = comm.ExecuteReader();
while (dr.Read())
{
txtresults.Text = dr.GetValue(0).ToString();
}
}
else
{
txtresults.Text = comm.ExecuteNonQuery().ToString();
}
}
catch (Exception ex)
{
txtresults.Text = ex.Message;
}
finally
{
comm.Dispose();
conn.Close();
conn = null;
}
}
示例10: GetWDSResults
public static System.Data.OleDb.OleDbDataReader GetWDSResults(IList<WDSField> fields, string scope, string extention, System.Data.OleDb.OleDbConnection wds_connection)
{
var fieldnames = System.String.Join(",", fields.Select(f => f.Name));
var sb = new System.Text.StringBuilder();
sb.AppendFormat(@"SELECT {0} ", fieldnames);
sb.AppendFormat(@"FROM SYSTEMINDEX ");
var clauses = new List<string>();
if (scope != null)
{
clauses.Add(string.Format(@"SCOPE='{0}' ", scope));
}
if (extention != null)
{
clauses.Add(string.Format(@"System.ItemType='{0}' ", extention));
}
if (clauses.Count > 0)
{
sb.AppendFormat(@"WHERE ");
int n = 0;
foreach (string clause in clauses)
{
if (n > 0)
{
sb.Append(" AND ");
}
sb.Append(clause);
n++;
}
}
string wds_query = sb.ToString();
var x = System.String.Format(
@"SELECT {0} FROM SYSTEMINDEX WHERE SCOPE='{1}' AND System.ItemType = '.mp3'", fieldnames, scope);
var wds_command = new System.Data.OleDb.OleDbCommand(wds_query, wds_connection);
return wds_command.ExecuteReader();
}
示例11: BulkCopyToDatabase
public void BulkCopyToDatabase()
{
using (System.Data.OleDb.OleDbConnection excelConnection = new System.Data.OleDb.OleDbConnection(_excelConnection))
{
try
{
excelConnection.Open();
using (System.Data.OleDb.OleDbCommand selectAllComand = new System.Data.OleDb.OleDbCommand("SELECT * FROM [" + _worksheetName + "$]"))
{
selectAllComand.Connection = excelConnection;
using (System.Data.OleDb.OleDbDataReader excelReader = selectAllComand.ExecuteReader())
{
//Gets scheme of datasheet to create table of same schema for bulk insert
System.Data.DataTable dt = excelReader.GetSchemaTable();
////Do the bulk insert
using (System.Data.SqlClient.SqlBulkCopy bc = new System.Data.SqlClient.SqlBulkCopy(_dbConn))
{
bc.BatchSize = 100;
bc.DestinationTableName = "[dbo].[" + _tempTableName + "]"; //tmpReleaseNumbers_BulkLoad]";
// User notification with the SqlRowsCopied event
//bc.NotifyAfter = 100;
//bc.SqlRowsCopied += new SqlRowsCopiedEventHandler(OnSqlRowsCopied);
if (_dbConn.State != System.Data.ConnectionState.Open)
_dbConn.Open();
bc.WriteToServer(excelReader);
bc.Close();
}
excelReader.Close();
_dbConn.Close();
}
}
}
catch (Exception ex)
{
throw new Exception("BulkCreate.PrattReleaseNumbers.CreateTempReleaseNumbers: " + ex.Message);
}
}
}
示例12: makeAll
/// <summary> <p>Creates skeletal source code (without correct data structure but no business
/// logic) for all segments found in the normative database. </p>
/// </summary>
public static void makeAll(System.String baseDirectory, System.String version)
{
//make base directory
if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/")))
{
baseDirectory = baseDirectory + "/";
}
System.IO.FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + SourceGenerator.getVersionPackageDirectory(version) + "segment");
//get list of data types
//UPGRADE_NOTE: There are other database providers or managers under System.Data namespace which can be used optionally to better fit the application requirements. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1208'"
System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
//UPGRADE_TODO: Method 'java.sql.Connection.createStatement' was converted to 'SupportClass.TransactionManager.manager.CreateStatement' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlConnectioncreateStatement'"
System.String sql = "SELECT seg_code, [section] from HL7Segments, HL7Versions where HL7Segments.version_id = HL7Versions.version_id AND hl7_version = '" + version + "'";
System.Data.OleDb.OleDbCommand temp_OleDbCommand = new System.Data.OleDb.OleDbCommand();
temp_OleDbCommand.Connection = conn;
temp_OleDbCommand.CommandText = sql;
System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
System.Collections.ArrayList segments = new System.Collections.ArrayList();
while (rs.Read())
{
System.String segName = System.Convert.ToString(rs[1 - 1]);
if (System.Char.IsLetter(segName[0]))
segments.Add(altSegName(segName));
}
//UPGRADE_ISSUE: Method 'java.sql.Statement.close' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javasqlStatementclose'"
temp_OleDbCommand.Dispose();
NormativeDatabase.Instance.returnConnection(conn);
if (segments.Count == 0)
{
//UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangSystem'"
log.warn("No version " + version + " segments found in database " + conn.Database);
}
for (int i = 0; i < segments.Count; i++)
{
try
{
System.String seg = (System.String) segments[i];
System.String source = makeSegment(seg, version);
//UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
//UPGRADE_TODO: Constructor 'java.io.FileWriter.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriterFileWriter_javalangString_boolean'"
//UPGRADE_TODO: Class 'java.io.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriter'"
using(System.IO.StreamWriter w = new System.IO.StreamWriter(targetDir.ToString() + "/" + seg + ".cs"))
{
w.Write(source);
w.Write("}");//Ending namespace
}
}
catch (System.Exception e)
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
System.Console.Error.WriteLine("Error creating source code for all segments: " + e.Message);
SupportClass.WriteStackTrace(e, Console.Error);
}
}
}
示例13: Task
void Task()
{
client = new myHost(new InstanceContext(this),"CustomBinding_IAmidaService");
while (!bexit)
{
try
{
string[] files = System.IO.Directory.GetFiles("c:\\export");
if (files.Length == 0)
continue;
foreach (string file in files)
{
try
{
Type DestType = null;
System.IO.FileStream fs = null;
System.IO.FileInfo fileinfo = new System.IO.FileInfo(file);
//if (fileinfo.Length <= 0)
// continue;
bool HasErr = true;
if (fileinfo.Length == 0)
continue;
if (fileinfo.Extension.ToUpper()==".MDB")
{
// continue;
System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + file);
try
{
cn.Open();
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("select * from VerifyNote",cn);
System.Data.OleDb.OleDbDataReader rd = cmd.ExecuteReader();
while (rd.Read())
{
VerifyNoteData data = new VerifyNoteData();
data.Fail = System.Convert.ToInt32(rd["Fail"]);
data.MAP = rd["Map"].ToString();
data.Operators = rd["Operators"].ToString();
data.Pass = System.Convert.ToInt32(rd["Pass"]);
data.PCID = rd["PCID"].ToString();
data.RCP = rd["RCP"].ToString();
data.StartTimes = System.Convert.ToDateTime(rd["StartTime"]);
data.StopTimes = System.Convert.ToDateTime(rd["StopTime"]);
data.TestVerify =rd["TestVerify"].ToString();
data.TestVerifyDate = System.Convert.ToDateTime(rd["TestVerifyDate"]);
data.TouchDo = System.Convert.ToInt64(rd["TouchDo"]);
data.TPS = rd["TPS"].ToString();
data.WaferID = rd["WaferID"].ToString();
//AmidaService.AmidaServiceClient client = new AmidaService.AmidaServiceClient();
System.Xml.Serialization.XmlSerializer sr = new System.Xml.Serialization.XmlSerializer(typeof(VerifyNoteData));
MemoryStream ms=new MemoryStream();
sr.Serialize(ms, data);
// client.InsertIntoVerifyNote(data);
client.ExportCommand(Environment.MachineName,"VerifyNoteData",System.Text.Encoding.UTF8.GetString(ms.ToArray()));
// client.Close();
HasErr = false;
}
}
catch (Exception ex1)
{
System.Diagnostics.EventLog verifylog = new System.Diagnostics.EventLog() { Source = "AmidaClientService" };
verifylog.WriteEntry(ex1.Message + "," + ex1.StackTrace);
Console.WriteLine(ex1.Message);
}
finally
{
cn.Close();
}
}
else
if (fileinfo.Name.ToUpper().StartsWith("VerifyNoteData".ToUpper()))
{
DestType = typeof(VerifyNoteData);
string xmlcmd = System.IO.File.ReadAllText(file);
//System.Xml.Serialization.XmlSerializer sz = new System.Xml.Serialization.XmlSerializer(DestType);
//VerifyNoteData data = sz.Deserialize(fs) as VerifyNoteData;
//Console.WriteLine(data.ToString());
// fs.Close();
// client.InsertIntoVerifyNote(data);
client.ExportCommand(Environment.MachineName,"VerifyNoteData", xmlcmd);
// client.Close();
HasErr = false;
}
if (!HasErr)
System.IO.File.Delete(file);
}
catch (Exception ex1)
//.........这里部分代码省略.........
示例14: ImportCourses
private void ImportCourses()
{
string last, first, connectionString="";
OpenFileDialog coursesFile = new OpenFileDialog();
coursesFile.Title = "Import Courses";
coursesFile.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
coursesFile.RestoreDirectory = true;
coursesFile.DefaultExt = "xlsx";
if (coursesFile.ShowDialog() == DialogResult.OK)
{
if (coursesFile.FileName == "")
return;
try
{
connectionString = @"Provider= Microsoft.ACE.OLEDB.12.0;Data Source=" + coursesFile.FileName + ";Extended Properties=Excel 12.0 Xml";
}
catch { return; };
}
else
return;
// Create the connection
this.Cursor = Cursors.WaitCursor;
System.Data.OleDb.OleDbConnection excelConnection = new System.Data.OleDb.OleDbConnection(connectionString);
string excelQuery = @"Select * from [sheet1$]";
System.Data.OleDb.OleDbCommand excelCommand = new System.Data.OleDb.OleDbCommand(excelQuery, excelConnection);
excelConnection.Open();
System.Data.OleDb.OleDbDataReader excelReader;
excelReader = excelCommand.ExecuteReader();
DataConnection conn = new DataConnection();
conn.Open();
string s = "";
int i=2;
excelReader.Read();
while (excelReader.Read())
{
i++;
last = excelReader[5].ToString();
last = last.Replace("'"," ");
first = excelReader[6].ToString();
first= first.Replace("'"," ");
string catalog = excelReader[3].ToString().Replace(" ", "");
try
{
conn.Query("insert into PROFESSOR (PROF_EMAIL, LASTNAME, FIRSTNAME) values ('" + excelReader[7] + "', '" + last + "', '" + first + "')");
}
catch (Exception ex)
{
s += "\n\tProfessor on row " + i.ToString() + "\n" + ex.Message.ToString();
}
try
{
conn.Query("insert into Course (term,subject,catalog,section,prof_email) values ('" + excelReader[0] + "','" + excelReader[2] + "','" + catalog + "','" + excelReader[4] + "','"+excelReader[7]+"')");
}
catch (Exception ex)
{
s += "\n\tCourse on row " + i.ToString() + "\n" + ex.Message.ToString();
}
try
{
conn.Query("insert into student_Course (clarion_id,term,subject,catalog,section) values ('"+excelReader[1]+"' ,'" + excelReader[0] + "','" + excelReader[2] + "','" + catalog + "','" + excelReader[4] + "')");
}
catch (Exception ex)
{
s += "\n\tStudent_Course on row " + i.ToString() + "\n" + ex.Message.ToString();
}
}
try
{
conn.Query("insert into Course (term,subject,catalog,section) values ('other','other','other','other')");
}
catch { }
excelReader.Close();
conn.Close();
excelConnection.Close();
this.Cursor = Cursors.Default;
}
示例15: GetResultWeaponClassesWithResults
internal Structs.ResultWeaponsClass[] GetResultWeaponClassesWithResults()
{
string select = "SELECT DISTINCT weapons.class " +
"FROM (weapons RIGHT JOIN Competitors ON weapons.WeaponId = Competitors.WeaponId) " +
"INNER JOIN CompetitorResults ON Competitors.CompetitorId = CompetitorResults.CompetitorId;";
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(
select, myInterface.databaseClass.Conn);
if (myInterface.databaseClass.Conn.State != ConnectionState.Open)
myInterface.databaseClass.Conn.Open();
System.Data.OleDb.OleDbDataReader r = cmd.ExecuteReader();
List<Structs.WeaponClass> wclasses = new List<Structs.WeaponClass>();
while (r.Read())
{
wclasses.Add((Structs.WeaponClass)r.GetInt32(0));
}
r.Dispose();
cmd.Dispose();
List<Structs.ResultWeaponsClass> rwclasses = new List<Structs.ResultWeaponsClass>();
foreach (Structs.WeaponClass wclass in wclasses)
{
// Check for duplicates
Structs.ResultWeaponsClass rwc=
CConvert.ConvertWeaponsClassToResultClass(
wclass,
myInterface.CompetitionCurrent.Type);
if (!rwclasses.Contains(rwc))
rwclasses.Add(rwc);
}
// Sort
rwclasses.Sort();
return rwclasses.ToArray();
}