本文整理汇总了C#中ADODB.Recordset.Close方法的典型用法代码示例。如果您正苦于以下问题:C# ADODB.Recordset.Close方法的具体用法?C# ADODB.Recordset.Close怎么用?C# ADODB.Recordset.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ADODB.Recordset
的用法示例。
在下文中一共展示了ADODB.Recordset.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: db_access
public object[] db_access(string strSQL)
{
ADODB.Connection objCon;
ADODB.Recordset objRec;
object[,] dataRows;
object[] dataSuite;
string strCon;
objCon = new ADODB.Connection();
objRec = new ADODB.Recordset();
//establish the connection string and open the database connection
strCon = "driver={MySQL ODBC 5.1 Driver};server=107.22.232.228;uid=qa_people;pwd=thehandcontrols;" +
"database=functional_test_data;option=3";
objCon.Open(strCon);
//execute the SQL and return the recrodset of results
objRec = objCon.Execute(strSQL, out missing, 0);
//populate a two dinmensional object array with the results
dataRows = objRec.GetRows();
//get a one dimensional array that can be placed into the Test Suite dropdown
dataSuite = thinArray(dataRows);
//close the recordset
objRec.Close();
//close the database connection
objCon.Close();
return dataSuite;
}
示例2: cmdsearch_Click
private void cmdsearch_Click(System.Object eventSender, System.EventArgs eventArgs)
{
int x = 0;
string sql = null;
string databaseName = null;
short y = 0;
short lMonth = 0;
ADODB.Connection cn = default(ADODB.Connection);
ADODB.Recordset rs = new ADODB.Recordset();
if (gLoading)
return;
gLoading = true;
Cursor = System.Windows.Forms.Cursors.WaitCursor;
System.Windows.Forms.Application.DoEvents();
//lMonth = cmbMonth.ItemData(cmbMonth.ListIndex)
//If lMonth = gMonthEnd Then
databaseName = "pricing.mdb";
//Else
// databaseName = "Month" & lMonth & ".mdb"
//End If
//If openConnection() Then
// frmMain.lblPath.Caption = serverPath
// closeConnection
//End If
//Set cn = openConnectionInstance(databaseName)
//If cn Is Nothing Then
// Exit Sub
//End If
//Dim lString As String
System.Windows.Forms.Application.DoEvents();
if (rs.State)
rs.Close();
sql = "SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_Reference, CustomerTransaction.CustomerTransaction_PersonName, CustomerTransaction.CustomerTransaction_Main, CustomerTransaction.CustomerTransaction_Child, CustomerTransaction.CustomerTransaction_Allocated," + " TransactionType.TransactionType_Name, IIf([CustomerTransaction_Amount]>0,[CustomerTransaction_Amount],Null) AS debit, IIf([CustomerTransaction_Amount]<0,[CustomerTransaction_Amount],Null) AS credit FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" + adoPrimaryRS.Fields("CustomerID").Value + ")) ORDER BY CustomerTransaction.CustomerTransactionID DESC;";
Debug.Print(sql);
//rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText
rs = modRecordSet.getRS(ref sql);
lvTransaction.Items.Clear();
lblcount.Text = "0 of 0";
System.Windows.Forms.ListViewItem lvItemTran = null;
x = 0;
lvTransaction.Visible = false;
while (!(rs.EOF)) {
x = x + 1;
if (gLoading) {
} else {
break; // TODO: might not be correct. Was : Exit Do
}
lblcount.Text = x + " of " + rs.RecordCount;
System.Windows.Forms.Application.DoEvents();
//If rs("CustomerTransaction_Reference") = "Month End" Then
if (rs.Fields("TransactionType_Name").Value == "B/Forward") {
if ((Information.IsDBNull(rs.Fields("debit").Value) ? 0 : rs.Fields("debit").Value) == rs.Fields("CustomerTransaction_Allocated").Value) {
} else if ((Information.IsDBNull(rs.Fields("credit").Value) ? 0 : rs.Fields("credit").Value) == rs.Fields("CustomerTransaction_Allocated").Value & (Information.IsDBNull(rs.Fields("credit").Value) ? 0 : rs.Fields("credit").Value) < 0) {
} else {
lvItemTran = lvTransaction.Items.Add("K" + rs.Fields("CustomerTransactionID").Value + "_" + databaseName + "_" + rs.Fields("CustomerTransaction_ReferenceID").Value + "_" + rs.Fields("CustomerTransaction_TransactionTypeID").Value, Strings.Format(rs.Fields("CustomerTransaction_Date").Value, "yyyy mmm dd hh:mm"), "");
if (lvItemTran.SubItems.Count > 1) {
lvItemTran.SubItems[1].Text = rs.Fields("CustomerTransaction_Reference").Value;
} else {
lvItemTran.SubItems.Insert(1, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, rs.Fields("CustomerTransaction_Reference").Value));
}
if (lvItemTran.SubItems.Count > 2) {
lvItemTran.SubItems[2].Text = rs.Fields("TransactionType_Name").Value;
} else {
lvItemTran.SubItems.Insert(2, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, rs.Fields("TransactionType_Name").Value));
}
//Select Case rs("Sale_PaymentType")
// Case 1
// lvItemTran.SubItems(2) = "Cash"
// Case 2
// lvItemTran.SubItems(2) = "CR Card"
// Case 3
// lvItemTran.SubItems(2) = "DR Card"
// Case 4
// lvItemTran.SubItems(2) = "Cheque"
// Case 5
// lvItemTran.SubItems(2) = "Account"
// Case 7
// lvItemTran.SubItems(2) = "Split Tender"
// Case Else
// lvItemTran.SubItems(2) = "Cash"
//End Select
if (lvItemTran.SubItems.Count > 3) {
lvItemTran.SubItems[3].Text = Strings.FormatNumber(rs.Fields("debit").Value, 4);
} else {
lvItemTran.SubItems.Insert(3, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Strings.FormatNumber(rs.Fields("debit").Value, 4)));
}
if (lvItemTran.SubItems.Count > 4) {
lvItemTran.SubItems[4].Text = Strings.FormatNumber(rs.Fields("credit").Value, 4);
} else {
lvItemTran.SubItems.Insert(4, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Strings.FormatNumber(rs.Fields("credit").Value, 4)));
}
if (lvItemTran.SubItems.Count > 5) {
lvItemTran.SubItems[5].Text = Strings.FormatNumber(rs.Fields("CustomerTransaction_Allocated").Value, 4);
} else {
lvItemTran.SubItems.Insert(5, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Strings.FormatNumber(rs.Fields("CustomerTransaction_Allocated").Value, 4)));
//.........这里部分代码省略.........
示例3: cmdInv_Click
private void cmdInv_Click(System.Object eventSender, System.EventArgs eventArgs)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
int personID = 0;
int posID = 0;
string[] lArray = null;
string lAddress = null;
//On Error Resume Next
ADODB.Connection cn = default(ADODB.Connection);
short x = 0;
string databaseName = null;
int lID = 0;
CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ADODB.Recordset rs = default(ADODB.Recordset);
ADODB.Recordset rsItems = default(ADODB.Recordset);
string sql = null;
//UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
if (lvTransaction.FocusedItem == null)
return;
//lID = Mid(Split(Me.lvTransaction.SelectedItem.Key, "_")(0), 2)
if (Convert.ToDouble(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[2]) == 0) {
Interaction.MsgBox("There is no Sale document attached!", MsgBoxStyle.Information);
System.Windows.Forms.Cursor.Current = Cursors.Default;
return;
}
lID = Convert.ToInt32(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[2]);
//If openConnection() Then
// frmMain.lblPath.Caption = serverPath
// closeConnection
//End If
//Set cn = openConnectionInstance()
//lMonth = cmbMonth.ItemData(cmbMonth.ListIndex)
//Dim lLineitem As lineitem
//If lMonth = gMonthEnd Then
// databaseName = ""
//Else
// databaseName = "Month" & lMonth & ".mdb"
//End If
databaseName = Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[1];
cn = modRecordSet.openConnectionInstance(ref databaseName);
if (cn == null) {
return;
}
transaction lTransaction = new transaction();
lineItem lLineitem = null;
customer lCustomer = new customer();
transactionSpecial lSpecial = new transactionSpecial();
if (Convert.ToDouble(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[3]) == 2) {
//sale
//Dim Report As New cryReceipt
//Set Report = New cryReceipt
rs = new ADODB.Recordset();
sql = "SELECT Sale.* From Sale WHERE (((SaleID)=" + lID + "));";
rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
if (rs.RecordCount) {
lTransaction.cashierID = rs.Fields("Sale_PersonID").Value;
lTransaction.channelID = rs.Fields("Sale_ChannelID").Value;
lTransaction.managerID = rs.Fields("Sale_ManagerID").Value;
lTransaction.paymentDiscount = rs.Fields("Sale_Discount").Value;
lTransaction.paymentSlip = rs.Fields("Sale_Slip").Value;
lTransaction.paymentSubTotal = rs.Fields("Sale_SubTotal").Value;
lTransaction.paymentTender = rs.Fields("Sale_Tender").Value;
lTransaction.paymentTotal = rs.Fields("Sale_Total").Value;
lTransaction.paymentType = rs.Fields("Sale_PaymentType").Value;
lTransaction.posID = rs.Fields("Sale_POSID").Value;
lTransaction.transactionDate = rs.Fields("Sale_DatePOS").Value;
lTransaction.transactionID = rs.Fields("Sale_Reference").Value + "";
lTransaction.transactionType = "Sale";
//If prPrevSerial_p = True Then strSerial = rs("Sale_Serialref")
rs.Close();
rs = modRecordSet.getRS(ref "SELECT * FROM Company");
lTransaction.companyName = rs.Fields("Company_Name").Value;
//gParameters.companyName
lTransaction.footer = " ";
//gParameters.footer & ""
lTransaction.heading1 = rs.Fields("Company_PhysicalAddress").Value;
//gParameters.heading1 & ""
lTransaction.heading2 = " ";
//gParameters.heading2 & ""
lTransaction.heading3 = " ";
//gParameters.heading3 & ""
lTransaction.taxNumber = rs.Fields("Company_TaxNumber").Value;
//gParameters.taxNumber & ""
rs.Close();
sql = "SELECT [Person_FirstName] & ' ' & [Person_LastName] AS personName From Person WHERE (((PersonID)=" + lTransaction.cashierID + "));";
rs = modRecordSet.getRS(ref sql);
//rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText
if (rs.RecordCount) {
lTransaction.cashierName = rs.Fields("personName").Value + "";
}
rs.Close();
//.........这里部分代码省略.........
示例4: cmdShowHistory_Click
private void cmdShowHistory_Click(System.Object eventSender, System.EventArgs eventArgs)
{
int i = 0;
int x = 0;
string sql = null;
string databaseName = null;
short y = 0;
short lMonth = 0;
ADODB.Connection cn = default(ADODB.Connection);
ADODB.Recordset rs = new ADODB.Recordset();
// ERROR: Not supported in C#: OnErrorStatement
if (cmdShowHistory.Text == "&Show Full History") {
cmdShowHistory.Text = "&Show Current Month";
} else {
cmdShowHistory.Text = "&Show Full History";
cmdsearch_Click(cmdSearch, new System.EventArgs());
return;
}
if (gLoading)
return;
gLoading = true;
Cursor = System.Windows.Forms.Cursors.WaitCursor;
System.Windows.Forms.Application.DoEvents();
y = cmbMonth.Items.Count - 1;
lvTransaction.Items.Clear();
lblcount.Text = "0 of 0";
lvTransaction.Visible = false;
string lPosString = null;
System.Windows.Forms.ListViewItem lvItem = null;
//(cmbMonth.ListCount - 1)
for (i = 0; i <= y; i++) {
lMonth = Convert.ToInt32(cmbMonth.Items[i]);
if (lMonth == gMonthEnd) {
databaseName = "pricing.mdb";
} else {
databaseName = "Month" + lMonth + ".mdb";
}
cn = modRecordSet.openConnectionInstance(ref databaseName);
if (cn == null) {
goto nextMonth;
//Exit Sub
}
//Dim lString As String
//Dim lCustomerString As String
//Dim lStockString As String
if (this.cmbPOS.SelectedIndex)
lPosString = " AND (Sale_PosID=" + cmbPOS.SelectedIndex + ")";
sql = "SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_Reference, CustomerTransaction.CustomerTransaction_PersonName," + " TransactionType.TransactionType_Name, IIf([CustomerTransaction_Amount]>0,[CustomerTransaction_Amount],Null) AS debit, IIf([CustomerTransaction_Amount]<0,[CustomerTransaction_Amount],Null) AS credit FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" + adoPrimaryRS.Fields("CustomerID").Value + ")) ORDER BY CustomerTransaction.CustomerTransactionID DESC;";
Debug.Print(sql);
rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
x = 0;
//lvTransaction.Visible = False
while (!(rs.EOF)) {
x = x + 1;
if (gLoading) {
} else {
break; // TODO: might not be correct. Was : Exit Do
}
lblcount.Text = x + " of " + rs.RecordCount;
System.Windows.Forms.Application.DoEvents();
if (rs.Fields("CustomerTransaction_Reference").Value != "Month End") {
lvItem = lvTransaction.Items.Add("K" + rs.Fields("CustomerTransactionID").Value + "_" + databaseName + "_" + rs.Fields("CustomerTransaction_ReferenceID").Value + "_" + rs.Fields("CustomerTransaction_TransactionTypeID").Value, Strings.Format(rs.Fields("CustomerTransaction_Date").Value, "yyyy mmm dd hh:mm"), "");
if (lvItem.SubItems.Count > 1) {
lvItem.SubItems[1].Text = rs.Fields("CustomerTransaction_Reference").Value;
} else {
lvItem.SubItems.Insert(1, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, rs.Fields("CustomerTransaction_Reference").Value));
}
if (lvItem.SubItems.Count > 2) {
lvItem.SubItems[2].Text = rs.Fields("TransactionType_Name").Value;
} else {
lvItem.SubItems.Insert(2, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, rs.Fields("TransactionType_Name").Value));
}
if (lvItem.SubItems.Count > 3) {
lvItem.SubItems[3].Text = Strings.FormatNumber(rs.Fields("debit").Value, 4);
} else {
lvItem.SubItems.Insert(3, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Strings.FormatNumber(rs.Fields("debit").Value, 4)));
}
if (lvItem.SubItems.Count > 4) {
lvItem.SubItems[4].Text = Strings.FormatNumber(rs.Fields("credit").Value, 4);
} else {
lvItem.SubItems.Insert(4, new System.Windows.Forms.ListViewItem.ListViewSubItem(null, Strings.FormatNumber(rs.Fields("credit").Value, 4)));
}
}
rs.moveNext();
}
//lvTransaction.Visible = True
rs.Close();
nextMonth:
}
lvTransaction.Visible = true;
//.........这里部分代码省略.........
示例5: bExportDataToSql
//.........这里部分代码省略.........
sString = "(" + rs.Fields["PropID"].Value + ",'" +
rs.Fields["PropertyAddress1"].Value + "','" +
rs.Fields["PropertyAddress2"].Value + "','" +
rs.Fields["PropertyAddress3"].Value + "'," +
rs.Fields["Price"].Value + ",'" +
rs.Fields["OffersOverEtc"].Value + "','" +
rs.Fields["cd"].Value + "','" +
rs.Fields["UnderOffer"].Value + "','" +
rs.Fields["PropertyAddress4"].Value + "','" +
rs.Fields["Postcode"].Value + "','" +
rs.Fields["RCCWOffice"].Value + "')";
//sString = " i = " + i + ", PropID = " + rs.Fields["PropID"].Value;
i++;
if (i<150)
{sString = sString + ",";
}
else
{
sString = sString + ";";
}
rs.MoveNext();
// Replace '' with NULL
sString = sString.Replace("''", "NULL");
// Force mysql null date format
sString = sString.Replace("30/12/1899 00:00:00", "1899-12-30 00:00:00");
if (!rs.EOF) { sw.WriteLine(sString); }
// end while
}
// End if
}
//sw.Close();
rs.Close();
// Replace last comma with a semi colon
// Replace '' with NULL
//sString = sString.Replace("''", "NULL");
sString = sString.Remove(sString.Length - 1, 1) + ";";
// Add the last line
sw.WriteLine(sString);
//
// Now do the accom
sw.WriteLine("");
sw.WriteLine("-- Purge accom table ...");
sw.WriteLine("DELETE FROM accom;");
sw.WriteLine("");
sw.WriteLine("-- Repopulate accom table ...");
rs.Open("SELECT * FROM accom ORDER BY PropID", conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1);
if (!rs.EOF)
{
sw.WriteLine(sAccomInsertIntoHeader);
while (!rs.EOF)
{
if (i == 150)
{
sw.WriteLine(sAccomInsertIntoHeader);
i = 0;
}
sWebsite = "";
sWebsite = rs.Fields["Website"].Value;
// strip any single quotes off website information
sWebsite = sWebsite.Replace("'", "");
sString = "(" + rs.Fields["PropID"].Value + "," +
"NULL" + ",'" +
sWebsite + "')";
示例6: backgroundWorker_DoWork
//.........这里部分代码省略.........
string study_time = ((DateTime)rs.Fields["study_timedate"].Value).ToString("s").Replace('T', ' ');
string creation_time = ((DateTime)rs.Fields["creation_timedate"].Value).ToString("s").Replace('T', ' ');
if (url.StartsWith("https"))
{
filename = https_url + filename;
}
else
{
filename = http_url + filename;
}
string note = "";
try
{
downloadFile(filename, notefile);
//client.DownloadFile(filename, notefile);
note = parseNote(notefile);
}
catch (Exception ex)
{
note = String.Format("Error downloading note at {0}: {1}", filename, ex.Message);
}
string name = (lastname + ", " + firstname + " " + middlename).Trim();
dt.Rows.Add(name, mrn, accnum, proc, study_time, creation_time, note, "");
rs.MoveNext();
pObj.dt = dt;
backgroundWorker.ReportProgress(0, pObj);
}
rs.Close();
File.Delete(tempfile);
int totalNotes = dt.Rows.Count;
int current = 0;
foreach (DataRow dr in dt.Rows)
{
// Retrieve reports here
query = String.Format(@"select * from storage s,document d,study_document sd,study st
where d.id = sd.document_uid
and s.id=d.storage_uid
and st.id=sd.study_uid
and d.name='Report'
and st.ris_study_euid='{0}'
order by d.creation_timedate", dr["Accession"]);
//dr["Reports"] = query;
result = retrieveRDS(uriFujiRDS, query);
if (result == null) return;
tempfile = Path.GetTempFileName();
ByteArrayToFile(tempfile, result);
rs.Open(tempfile, "Provider=MSPersist", ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0);
string report = "";
while (!rs.EOF)
{
string http_url = rs.Fields["http_url"].Value.ToString();
string https_url = rs.Fields["https_url"].Value.ToString();
string doctype = rs.Fields["name"].Value.ToString();
string filename = rs.Fields["filename"].Value.ToString();
示例7: TestRefreshDataTableWithADODBRecordSet_Schema
public void TestRefreshDataTableWithADODBRecordSet_Schema()
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
DataSet stuDS = new DataSet();
DataTable stuTable = new DataTable("student");
stuDS.Tables.Add(stuTable);
//Use ADO objects from ADO library (msado15.dll) imported
// as.NET library ADODB.dll using TlbImp.exe
ADODB.Connection adoConn = new ADODB.Connection();
ADODB.Recordset adoRS = new ADODB.Recordset();
adoConn.Open("Provider=CUBRIDProvider;Location=test-db-server;Data Source=demodb;User Id=dba;Port=30000", "", "", -1);
adoRS.Open("SELECT * FROM student", adoConn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, 1);
adapter.Fill(stuTable, adoRS);
adoRS.Requery(0);
int refreshRowCount = adapter.Fill(stuTable, adoRS); // This method does not call Close on the ADO object when the fill operation is complete.
adoRS.Close();
adoConn.Close();
Assert.IsNotNull(stuTable.PrimaryKey);
Assert.AreEqual(3, refreshRowCount);
}
示例8: Main
//.........这里部分代码省略.........
"CountryRegionCode", // 参数名
ADODB.DataTypeEnum.adVarChar, // 参数类型 (nvarchar(20))
ADODB.ParameterDirectionEnum.adParamInput, // 参数类型
20, // 参数的最大长度
"ZZ"+DateTime.Now.Millisecond); // 参数值
cmdInsert.Parameters.Append(paramCode);
// Name (nvarchar(200))参数的添加
ADODB.Parameter paramName = cmdInsert.CreateParameter(
"Name", // 参数名
ADODB.DataTypeEnum.adVarChar, // 参数类型 (nvarchar(200))
ADODB.ParameterDirectionEnum.adParamInput, // 参数传递方向
200, // 参数的最大长度
"Test Region Name"); // 参数值
cmdInsert.Parameters.Append(paramName);
// ModifiedDate (datetime)参数的添加
ADODB.Parameter paramModifiedDate = cmdInsert.CreateParameter(
"ModifiedDate", // 参数名
ADODB.DataTypeEnum.adDate, // 参数类型 (datetime)
ADODB.ParameterDirectionEnum.adParamInput, // 参数传递方向
-1, // 参数的最大长度 (datetime忽视该值)
DateTime.Now); // 参数值
cmdInsert.Parameters.Append(paramModifiedDate);
// 6. 执行命令
object nRecordsAffected = Type.Missing;
object oParams = Type.Missing;
cmdInsert.Execute(out nRecordsAffected, ref oParams,
(int)ADODB.ExecuteOptionEnum.adExecuteNoRecords);
////////////////////////////////////////////////////////////////////////////////
// 使用Recordset对象.
// http://msdn.microsoft.com/en-us/library/ms681510.aspx
// Recordset表示了数据表中记录或执行命令获得的结果的集合。
// 在任何时候, Recordset对象都指向集合中的单条记录,并将
// 该记录作为它的当前记录。
//
Console.WriteLine("列出表CountryRegion中的所有记录");
// 1. 生成Recordset对象
rs = new ADODB.Recordset();
// 2. 打开Recordset对象
string strSelectCmd = "SELECT * FROM CountryRegion"; // WHERE ...
rs.Open(strSelectCmd, // SQL指令/表,视图名 /
// 存储过程调用 /文件名
conn, // 连接对象/连接字符串
ADODB.CursorTypeEnum.adOpenForwardOnly, // 游标类型. (只进游标)
ADODB.LockTypeEnum.adLockOptimistic, // 锁定类型. (仅当需要调用
// 更新方法时,才锁定记录)
(int)ADODB.CommandTypeEnum.adCmdText); // 将第一个参数视为SQL命令
// 或存储过程.
// 3. 通过向前移动游标列举记录
// 移动到Recordset中的第一条记录
rs.MoveFirst();
while (!rs.EOF)
{
// 当在表中定义了一个可空字段,需要检验字段中的值是否为DBNull.Value.
string code = (rs.Fields["CountryRegionCode"].Value == DBNull.Value) ?
"(DBNull)" : rs.Fields["CountryRegionCode"].Value.ToString();
string name = (rs.Fields["Name"].Value == DBNull.Value) ?
"(DBNull)" : rs.Fields["Name"].Value.ToString();
DateTime modifiedDate = (rs.Fields["ModifiedDate"].Value == DBNull.Value) ?
DateTime.MinValue : (DateTime)rs.Fields["ModifiedDate"].Value;
Console.WriteLine(" {2} \t{0}\t{1}", code, name, modifiedDate.ToString("yyyy-MM-dd"));
// 移动到下一条记录
rs.MoveNext();
}
}
catch (Exception ex)
{
Console.WriteLine("应用程序出现错误: {0}", ex.Message);
if (ex.InnerException != null)
Console.WriteLine("描述: {0}", ex.InnerException.Message);
}
finally
{
////////////////////////////////////////////////////////////////////////////////
// 退出前清理对象.
//
Console.WriteLine("正在关闭连接 ...");
// 关闭record set,当它处于打开状态时
if (rs != null && rs.State == (int)ADODB.ObjectStateEnum.adStateOpen)
rs.Close();
// 关闭数据库连接,当它处于打开状态时
if (conn != null && conn.State == (int)ADODB.ObjectStateEnum.adStateOpen)
conn.Close();
}
}
示例9: getAddress
public string getAddress()
{
try
{
Position PoiX = new Position();
PoiX.X = Lat; PoiX.Y = Lon;
double tempLen = 1000000;
string tempTown = "";
ADODB.Recordset RST = new ADODB.Recordset();
string sqlSTR = "SELECT name,the_geom FROM mergedpoints WHERE the_geom && 'BOX3D(" +
(Lon - 0.5) + " " + (Lat - 0.5) + "," + (Lon + 0.5) + " " + (Lat + 0.5) +
") '::box3d AND distance( the_geom, GeometryFromText( 'POINT(" + Lon + " " + Lat +
")', -1 ) ) < 0.5";
string sqlSTROther = "SELECT name,the_geom FROM mergedpoints WHERE the_geom && 'BOX3D(" +
(Lon - 6) + " " + (Lat - 6) + "," + (Lon + 6) + " " + (Lat + 6) +
") '::box3d AND distance( the_geom, GeometryFromText( 'POINT(" + Lon + " " + Lat +
")', -1 ) ) < 7";
RST.Open(sqlSTR, this.odbcDatabaseConnection, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockBatchOptimistic, 0);
if (RST.EOF == true)
{
try { RST.Close(); }
catch { }
RST.Open(sqlSTROther, this.odbcDatabaseConnection, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockBatchOptimistic, 0);
}
if (RST.EOF == false)
{
RST.MoveFirst();
while (RST.EOF == false)
{
string Coord = RST.Fields["the_geom"].Value.ToString();
int Len = Coord.Length;
Coord = Right(Coord, (Len - 14));
Len = Coord.Length;
Coord = Mid(Coord, 0, (Len - 1));
char[] SepChar = { ' ' };
Array coordArray = Coord.Split(SepChar);
double xlon = Convert.ToDouble(coordArray.GetValue(0).ToString());
double xlat = Convert.ToDouble(coordArray.GetValue(1).ToString());
Position PoiY = new Position();
PoiY.X = xlat; PoiY.Y = xlon;
Calculations calc = new Calculations();
double xLen = calc.CalculateDistace(PoiX, PoiY);
//MessageBox.Show(xLen.ToString());
if (xLen < tempLen)
{
tempLen = xLen;
tempTown = RST.Fields["name"].Value.ToString();
}
//PoiY = null;
coordArray = null;
RST.MoveNext();
}
RST.Close();
RST = null;
}
if (tempLen != 1000000)
{
string retVal = Decimal.Round((decimal)tempLen, 3).ToString();
return retVal + "Km From " + tempTown;
}
else
{
return " ";
}
}
catch (System.Exception qw) { return " "; }
}
示例10: getRoadName
public string getRoadName()
{
try
{
Position PoiX = new Position();
PoiX.X = Lat; PoiX.Y = Lon;
double tempLen = 1000000;
string tempTown = "";
ADODB.Recordset RST = new ADODB.Recordset();
/* string sqlSTR = "SELECT name,the_geom FROM " + this.roadsTableName +" WHERE the_geom && 'BOX3D(" +
(Lon - 0.1) + " " + (Lat - 0.1) + "," + (Lon + 0.1) + " " + (Lat + 0.1) +
") '::box3d AND distance( the_geom, GeometryFromText( 'POINT(" + Lon + " " + Lat +
")', -1 ) ) < 0.11";
string sqlSTROther = "SELECT name,the_geom FROM " + this.roadsTableName + " WHERE the_geom && 'BOX3D(" +
(Lon - 1) + " " + (Lat - 1) + "," + (Lon + 1) + " " + (Lat + 1) +
") '::box3d AND distance( the_geom, GeometryFromText( 'POINT(" + Lon + " " + Lat +
")', -1 ) ) < 1.1";*/
string sqlSTR = "SELECT rd_name,the_geom FROM kRoads WHERE the_geom && 'BOX3D(" +
(Lon - 0.1) + " " + (Lat - 0.1) + "," + (Lon + 0.1) + " " + (Lat + 0.1) +
") '::box3d AND distance( the_geom, GeometryFromText( 'POINT(" + Lon + " " + Lat +
")', -1 ) ) < 0.11";
string sqlSTROther = "SELECT rd_name,the_geom FROM kRoads WHERE the_geom && 'BOX3D(" +
(Lon - 1) + " " + (Lat - 1) + "," + (Lon + 1) + " " + (Lat + 1) +
") '::box3d AND distance( the_geom, GeometryFromText( 'POINT(" + Lon + " " + Lat +
")', -1 ) ) < 1.1";
RST.Open(sqlSTR, this.odbcDatabaseConnection, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockBatchOptimistic, 0);
if (RST.EOF == true)
{
try { RST.Close(); }
catch { }
RST.Open(sqlSTROther, this.odbcDatabaseConnection, ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockBatchOptimistic, 0);
}
if (RST.EOF == false)
{
RST.MoveFirst();
while (RST.EOF == false)
{
/*we are no longer dealing with a single point we are
* dealind with a line string*/
string Coord = RST.Fields["the_geom"].Value.ToString();
int Len = Coord.Length;
Coord = Right(Coord, (Len - 25));
Len = Coord.Length;
Coord = Mid(Coord, 0, (Len - 2));
char[] SepChar = { ',' };
Array pointArray = Coord.Split(SepChar);
/*lets loop through the line string*/
for (int p = 0; p < pointArray.Length; p++)
{
try
{
char[] pointSep = { ' ' };
Array coordArray = pointArray.GetValue(p).ToString().Split(pointSep);
double xlon = Convert.ToDouble(coordArray.GetValue(0).ToString());
double xlat = Convert.ToDouble(coordArray.GetValue(1).ToString());
Position PoiY = new Position();
PoiY.X = xlat; PoiY.Y = xlon;
Calculations calc = new Calculations();
double xLen = 10000001;
try { xLen = calc.CalculateDistace(PoiX, PoiY); }
catch { }
calc = null;
//MessageBox.Show(xLen.ToString());
if (xLen < tempLen)
{
tempLen = xLen;
if (tempLen > 0.5)
{ tempTown = " Along Unknown Road"; }
else
{ tempTown = " Along " + RST.Fields["rd_name"].Value.ToString(); }
}
//PoiY = null;
coordArray = null;
//Application.DoEvents();
}
catch { }
}
//Application.DoEvents();
RST.MoveNext();
}
RST.Close();
RST = null;
}
if (tempLen != 1000000)
{
//.........这里部分代码省略.........
示例11: ExportToCSV
public void ExportToCSV(bool PrintHeader = true)
{
string ExportFilePath = null;
ADODB.Recordset rs = default(ADODB.Recordset);
int i = 0;
int TotalRecords = 0;
bool ErrorOccured = false;
short NumberOfFields = 0;
const string quote = "\"";
//Faster then Chr$(34)
string sql = null;
Scripting.FileSystemObject fso = new Scripting.FileSystemObject();
cmdStart.Enabled = false;
cmdExit.Enabled = false;
txtPassword.Enabled = false;
string ptbl = null;
string t_day = null;
string t_Mon = null;
if (Strings.Len(Strings.Trim(Conversion.Str(DateAndTime.Day(DateAndTime.Today)))) == 1)
t_day = "0" + Strings.Trim(Convert.ToString(DateAndTime.Day(DateAndTime.Today)));
else
t_day = Convert.ToString(DateAndTime.Day(DateAndTime.Today));
if (Strings.Len(Strings.Trim(Conversion.Str(DateAndTime.Month(DateAndTime.Today)))) == 1)
t_Mon = "0" + Strings.Trim(Convert.ToString(DateAndTime.Month(DateAndTime.Today)));
else
t_Mon = Conversion.Str(DateAndTime.Month(DateAndTime.Today));
ExportFilePath = modRecordSet.serverPath + "4POSDebtor" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(t_Mon) + Strings.Trim(t_day);
if (fso.FileExists(ExportFilePath + ".csv"))
fso.DeleteFile((ExportFilePath + ".csv"));
rs = modRecordSet.getRS(ref "SELECT CustomerID, Customer_InvoiceName, Customer_DepartmentName, Customer_FirstName, Customer_Surname, Customer_PhysicalAddress, Customer_PostalAddress, Customer_Telephone, Customer_Current as CurrentBalance,Customer_30Days as 30Days, Customer_60Days as 60days, Customer_90Days as 90Days, Customer_120Days as 120Days,Customer_150Days as 150Days FROM Customer");
prgBar.Maximum = rs.RecordCount;
if (rs.RecordCount > 0) {
FileSystem.FileOpen(1, ExportFilePath + ".csv", OpenMode.Output);
var _with2 = modRecordSet.getRS(ref ref "SELECT CustomerID, Customer_InvoiceName, Customer_DepartmentName, Customer_FirstName, Customer_Surname, Customer_PhysicalAddress, Customer_PostalAddress, Customer_Telephone, Customer_Current as CurrentBalance,Customer_30Days as 30Days, Customer_60Days as 60days, Customer_90Days as 90Days, Customer_120Days as 120Days,Customer_150Days as 150Days FROM Customer");
rs.MoveFirst();
NumberOfFields = rs.Fields.Count - 1;
if (PrintHeader) {
//Now add the field names
for (i = 0; i <= NumberOfFields - 1; i++) {
FileSystem.Print(1, rs.Fields(i).name + ",");
//similar to the ones below
}
FileSystem.PrintLine(1, rs.Fields(NumberOfFields).name);
}
while (!rs.EOF) {
prgBar.Value = prgBar.Value + 1;
// ERROR: Not supported in C#: OnErrorStatement
TotalRecords = TotalRecords + 1;
//If there is an emty field,
for (i = 0; i <= NumberOfFields; i++) {
//add a , to indicate it is
if ((Information.IsDBNull(rs.Fields(i).Value))) {
FileSystem.Print(1, ",");
//empty
} else {
if (i == NumberOfFields) {
FileSystem.Print(1, quote + Strings.Trim(Convert.ToString(rs.Fields(i).Value)) + quote);
} else {
FileSystem.Print(1, quote + Strings.Trim(Convert.ToString(rs.Fields(i).Value)) + quote + ",");
}
}
//Putting data under "" will not
}
//confuse the reader of the file
DoEventsEx();
//between Dhaka, Bangladesh as two
FileSystem.PrintLine(1);
//fields or as one field.
rs.moveNext();
}
FileSystem.FileClose(1);
Interaction.MsgBox("Customer details were successfully exported to : " + FilePath + "" + "4POSProd" + Strings.Trim(Convert.ToString(DateAndTime.Year(DateAndTime.Today))) + Strings.Trim(t_Mon) + Strings.Trim(t_day) + ".csv", MsgBoxStyle.OkOnly, "Customers");
// DoEvents
// DoEvents
// MsgBox "Now Zeroising...", vbOKOnly, "Customers"
// cmdStart.Enabled = False
// cmdExit.Enabled = False
// Set rsZ = getRS("SELECT CustomerID FROM Customer")
// Do While Not rsZ.EOF
// DoEvents
// cmdProcess_Click (rsZ("CustomerID"))
// DoEvents
// rsZ.moveNext
// Loop
//.........这里部分代码省略.........
示例12: CopyTable
//.........这里部分代码省略.........
strInfile += "ESCAPED BY '\\\\' ";
strInfile += "LINES TERMINATED BY 0x0d0a ";
strInfile += "(";
//loop through fields to enumerate them for the infile and build a select statement
for (intLoop = 0; intLoop < tblAccess.Columns.Count; intLoop++)
{
strInfile += MySQLName((tblAccess.Columns[intLoop].Name));
switch (tblAccess.Columns[intLoop].Type)
{
case ADOX.DataTypeEnum.adDate: //convert to MySQL datetime format
strSQL += "FORMAT([" + tblAccess.Columns[intLoop].Name + "], 'YYYY-MM-DD HH:MM:SS') as " + tblAccess.Columns[intLoop].Name;
break;
default:
strSQL += "[" + tblAccess.Columns[intLoop].Name + "]";
break;
}
if (intLoop < tblAccess.Columns.Count - 1)
{
strSQL += ",";
strInfile += ", ";
}
}
strInfile += ");";
strSQL += " FROM [" + tblAccess.Name + "]";
//open the "Master" recordset
recMaster.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
recMaster.Open(strSQL, conJCMS_db, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, 0);
//create the "Loop" recordset, this is a clone of the master, with the exception
//that the definedsize for text fields is lengthened. This is because the added
//escape characters could potentially exceed the field length in the master recordset
recLoop.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
ADODB.Fields fdsLoop = recLoop.Fields;
ADODB.Fields fdsMaster = recMaster.Fields;
foreach (ADODB.Field fldIn in fdsMaster)
{
if (fldIn.Type.ToString().IndexOf("Char") > 0)
{
fdsLoop.Append(fldIn.Name,
fldIn.Type,
fldIn.DefinedSize + 30,
ADODB.FieldAttributeEnum.adFldIsNullable,
null);
}
else
{
fdsLoop.Append(fldIn.Name,
fldIn.Type,
fldIn.DefinedSize,
ADODB.FieldAttributeEnum.adFldIsNullable,
null);
}
}
recLoop.Open(System.Reflection.Missing.Value, System.Reflection.Missing.Value, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, 0);
recLoop.AddNew(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
while (!recMaster.EOF)
{
for (int columnIndex = 0; columnIndex < recMaster.Fields.Count; columnIndex++)
{
recLoop.Fields[columnIndex].Value = recMaster.Fields[columnIndex].Value;
if (recLoop.Fields[columnIndex].Value.ToString().Length > 0)
{
if ((recLoop.Fields[columnIndex].Value.ToString().IndexOf("\\", 0) + 1) > 0)
{
recLoop.Fields[columnIndex].Value = recLoop.Fields[columnIndex].Value.ToString().Replace("\\", "\\\\");
}
if ((recLoop.Fields[columnIndex].Value.ToString().IndexOf(",", 0) + 1) > 0)
{
recLoop.Fields[columnIndex].Value = recLoop.Fields[columnIndex].Value.ToString().Replace(",", "\\,");
}
if ((recLoop.Fields[columnIndex].Value.ToString().IndexOf(System.Environment.NewLine, 0) + 1) > 0)
{
recLoop.Fields[columnIndex].Value = recLoop.Fields[columnIndex].Value.ToString().Replace(System.Environment.NewLine, " ");
}
}
}
strRecord = recLoop.GetString(ADODB.StringFormatEnum.adClipString, 1, ",", System.Environment.NewLine, "\\N");
recLoop.MovePrevious();
sw.Write(strRecord);
recMaster.MoveNext();
}
recMaster.Close();
recMaster.ActiveConnection = null;
try
{
recLoop.Close();
}
catch
{
}
sw.Close();
ExecuteSQL(strInfile);
File.Delete(strFileName);
recLoop = null;
}
示例13: cmdPrintHistory_Click
//.........这里部分代码省略.........
if (gLoading)
return;
gLoading = true;
Cursor = System.Windows.Forms.Cursors.WaitCursor;
System.Windows.Forms.Application.DoEvents();
y = cmbMonth.Items.Count - 1;
//lvTransaction.ListItems.Clear
//lblcount.Caption = "0 of 0"
//lvTransaction.Visible = False
sql = "DELETE tempCustomerHistory.* FROM tempCustomerHistory;";
modRecordSet.cnnDB.Execute(sql);
string lPosString = null;
//(cmbMonth.ListCount - 1)
for (i = 0; i <= y; i++) {
lMonth = Convert.ToInt32(cmbMonth.SelectedItem(i));
if (lMonth == gMonthEnd) {
databaseName = "pricing.mdb";
} else {
databaseName = "Month" + lMonth + ".mdb";
}
cn = modRecordSet.openConnectionInstance(ref databaseName);
if (cn == null) {
goto nextMonth;
//Exit Sub
}
//Dim lString As String
//Dim lCustomerString As String
//Dim lStockString As String
if (this.cmbPOS.SelectedIndex)
lPosString = " AND (Sale_PosID=" + cmbPOS.SelectedIndex + ")";
sql = "SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_Reference, CustomerTransaction.CustomerTransaction_PersonName," + " TransactionType.TransactionType_Name, IIf([CustomerTransaction_Amount]>0,[CustomerTransaction_Amount],Null) AS debit, IIf([CustomerTransaction_Amount]<0,[CustomerTransaction_Amount],Null) AS credit FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" + adoPrimaryRS.Fields("CustomerID").Value + ") AND (CustomerTransaction.CustomerTransaction_MonthEndID=(" + lMonth + "))) ORDER BY CustomerTransaction.CustomerTransactionID DESC;";
sql = "SELECT * FROM CustomerTransaction WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" + adoPrimaryRS.Fields("CustomerID").Value + ") AND (CustomerTransaction.CustomerTransaction_MonthEndID=(" + lMonth + "))) ORDER BY CustomerTransaction.CustomerTransactionID DESC;";
Debug.Print(sql);
rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
//Dim lvItem As listItem
x = 0;
//lvTransaction.Visible = False
while (!(rs.EOF)) {
x = x + 1;
if (gLoading) {
} else {
break; // TODO: might not be correct. Was : Exit Do
}
bResetError:
//lblcount.Caption = x & " of " & rs.RecordCount
System.Windows.Forms.Application.DoEvents();
if (bReset) {
bReset = false;
// ERROR: Not supported in C#: OnErrorStatement
sql = "INSERT INTO tempCustomerHistory ( CustomerTransactionID, CustomerTransaction_CustomerID, CustomerTransaction_TransactionTypeID, CustomerTransaction_DayEndID, CustomerTransaction_MonthEndID, CustomerTransaction_ReferenceID, CustomerTransaction_Date, CustomerTransaction_Description, CustomerTransaction_Amount, CustomerTransaction_Reference, CustomerTransaction_PersonName, CustomerTransaction_Done ) ";
sql = sql + "SELECT " + rs.Fields("CustomerTransactionID").Value + ", " + rs.Fields("CustomerTransaction_CustomerID").Value + ", " + rs.Fields("CustomerTransaction_TransactionTypeID").Value + ", " + rs.Fields("CustomerTransaction_DayEndID").Value + ", " + rs.Fields("CustomerTransaction_MonthEndID").Value + ", " + rs.Fields("CustomerTransaction_ReferenceID").Value + ", #" + rs.Fields("CustomerTransaction_Date").Value + "#, '" + rs.Fields("CustomerTransaction_Description").Value + "', " + rs.Fields("CustomerTransaction_Amount").Value + ", '" + rs.Fields("CustomerTransaction_Reference").Value + "', '" + rs.Fields("CustomerTransaction_PersonName").Value + "', " + rs.Fields("CustomerTransaction_Done").Value + ";";
modRecordSet.cnnDB.Execute(sql);
} else {
sql = "INSERT INTO tempCustomerHistory ( CustomerTransactionID, CustomerTransaction_CustomerID, CustomerTransaction_TransactionTypeID, CustomerTransaction_DayEndID, CustomerTransaction_MonthEndID, CustomerTransaction_ReferenceID, CustomerTransaction_Date, CustomerTransaction_Description, CustomerTransaction_Amount, CustomerTransaction_Reference, CustomerTransaction_PersonName, CustomerTransaction_Done, CustomerTransaction_Main, CustomerTransaction_Child, CustomerTransaction_Allocated ) ";
sql = sql + "SELECT " + rs.Fields("CustomerTransactionID").Value + ", " + rs.Fields("CustomerTransaction_CustomerID").Value + ", " + rs.Fields("CustomerTransaction_TransactionTypeID").Value + ", " + rs.Fields("CustomerTransaction_DayEndID").Value + ", " + rs.Fields("CustomerTransaction_MonthEndID").Value + ", " + rs.Fields("CustomerTransaction_ReferenceID").Value + ", #" + rs.Fields("CustomerTransaction_Date").Value + "#, '" + rs.Fields("CustomerTransaction_Description").Value + "', " + rs.Fields("CustomerTransaction_Amount").Value + ", '" + rs.Fields("CustomerTransaction_Reference").Value + "', '" + rs.Fields("CustomerTransaction_PersonName").Value + "', " + rs.Fields("CustomerTransaction_Done").Value + ", " + rs.Fields("CustomerTransaction_Main").Value + ", " + rs.Fields("CustomerTransaction_Child").Value + ", " + rs.Fields("CustomerTransaction_Allocated").Value + ";";
modRecordSet.cnnDB.Execute(sql);
}
//If rs("CustomerTransaction_Reference") <> "Month End" Then
// Set lvItem = lvTransaction.ListItems.Add(, "K" & rs("CustomerTransactionID") & "_" & databaseName & "_" & rs("CustomerTransaction_ReferenceID") & "_" & rs("CustomerTransaction_TransactionTypeID"), Format(rs("CustomerTransaction_Date"), "yyyy mmm dd hh:mm"))
// lvItem.SubItems(1) = rs("CustomerTransaction_Reference")
// lvItem.SubItems(2) = rs("TransactionType_Name")
// lvItem.SubItems(3) = FormatNumber(rs("debit"), 2)
// lvItem.SubItems(4) = FormatNumber(rs("credit"), 2)
//End If
rs.MoveNext();
}
//lvTransaction.Visible = True
rs.Close();
nextMonth:
}
//lvTransaction.Visible = True
report_CustomerStatementFullHistory(ref adoPrimaryRS.Fields("CustomerID").Value);
Cursor = System.Windows.Forms.Cursors.Default;
gLoading = false;
return;
ErrShowHistory:
if (Strings.InStr(Strings.LCase(Err().Description), "not a valid path")) {
Interaction.MsgBox(Err().Number + " - " + Err().Description);
return;
} else if (Err().Number == Convert.ToDouble("3265")) {
bReset = true;
//Resume bResetError
} else {
Interaction.MsgBox(Err().Number + " - " + Err().Description);
return;
// ERROR: Not supported in C#: ResumeStatement
}
}
示例14: report_CustomerStatementFullHistory
public void report_CustomerStatementFullHistory(ref int id)
{
ADODB.Recordset rsInterest = default(ADODB.Recordset);
ADODB.Recordset rsTransaction = default(ADODB.Recordset);
ADODB.Recordset rsCompany = default(ADODB.Recordset);
string lNumber = null;
string lAddress = null;
ADODB.Recordset rs = new ADODB.Recordset();
string sql = null;
//Dim Report As New cryCustomerStatementFull
CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
System.DateTime lDate = default(System.DateTime);
short gMonth = 0;
ADODB.Connection cnnDBStatement = new ADODB.Connection();
Report.Load("cryCustomerStatementFull.rpt");
var _with1 = cnnDBStatement;
_with1.Provider = "MSDataShape";
cnnDBStatement.Open("Data Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + modRecordSet.serverPath + "pricing.mdb" + ";User Id=liquid;Password=lqd;Jet OLEDB:System Database=" + modRecordSet.serverPath + "Secured.mdw");
rs = modRecordSet.getRS(ref "SELECT Company_MonthendID FROM Company;");
if (rs.Fields("Company_MonthendID").Value <= 1) {
gMonth = 1;
} else {
gMonth = rs.Fields("Company_MonthendID").Value;
//- 1
}
rs = modRecordSet.getRS(ref "SELECT MonthEnd.MonthEnd_Date From MonthEnd WHERE (((MonthEnd.MonthEndID)=" + gMonth + "));");
//rs.Open "SELECT MonthEnd.MonthEnd_Date From MonthEnd WHERE (((MonthEnd.MonthEndID)=" & gMonth & "));", cnnDBStatement, adOpenStatic, adLockReadOnly, adCmdText
if (Information.IsDBNull(rs.Fields("MonthEnd_Date").Value) == true | rs.RecordCount == 0) {
gMonth = 1;
rs = modRecordSet.getRS(ref "SELECT MonthEnd.MonthEnd_Date From MonthEnd WHERE (((MonthEnd.MonthEndID)=" + gMonth + "));");
}
Report.SetParameterValue("txtStatementDate", Strings.Format(DateAndTime.Today, "dd mmm yyyy"));
if (rs.RecordCount) {
//Report.txtStatementDate.SetText Format(rs("MonthEnd_Date"), "dd mmm yyyy")
lDate = rs.Fields("MonthEnd_Date").Value;
} else {
}
rs.Close();
rs = modRecordSet.getRS(ref "SELECT * FROM Company");
lDate = System.Date.FromOADate(lDate.ToOADate() + 10);
lDate = DateAndTime.DateSerial(DateAndTime.Year(lDate), DateAndTime.Month(lDate), 1);
lDate = System.Date.FromOADate(lDate + rs.Fields("Company_PaymentDay").Value - 1);
//Report.txtPaymentDate.SetText Format(lDate, "dd mmm yyyy")
lAddress = Strings.Replace(rs.Fields("Company_PhysicalAddress").Value, Constants.vbCrLf, ", ");
if (Strings.Right(lAddress, 2) == ", ") {
lAddress = Strings.Left(lAddress, Strings.Len(lAddress) - 2);
}
Report.Database.Tables(1).SetDataSource(rs);
Report.SetParameterValue("txtAddress", lAddress);
lNumber = "";
if (!string.IsNullOrEmpty(rs.Fields("Company_Telephone").Value))
lNumber = lNumber + "Tel: " + rs.Fields("Company_Telephone").Value;
if (!string.IsNullOrEmpty(rs.Fields("Company_Fax").Value)) {
if (!string.IsNullOrEmpty(lNumber))
lNumber = lNumber + " / ";
lNumber = lNumber + "Fax: " + rs.Fields("Company_Fax").Value;
}
if (!string.IsNullOrEmpty(rs.Fields("Company_Email").Value)) {
if (!string.IsNullOrEmpty(lNumber))
lNumber = lNumber + " / ";
lNumber = lNumber + "Email: " + rs.Fields("Company_Email").Value;
}
Report.SetParameterValue("txtNumbers", lNumber);
//New banking details
if (Information.IsDBNull(rs.Fields("Company_BankName").Value)) {
} else {
Report.SetParameterValue("txtBankName", rs.Fields("Company_BankName"));
}
if (Information.IsDBNull(rs.Fields("Company_BranchName").Value)) {
} else {
Report.SetParameterValue("txtBranchName", rs.Fields("Company_BranchName"));
}
if (Information.IsDBNull(rs.Fields("Company_BranchCode").Value)) {
} else {
Report.SetParameterValue("txtBranchCode", rs.Fields("Company_BranchCode"));
}
if (Information.IsDBNull(rs.Fields("Company_AccountNumber").Value)) {
} else {
Report.SetParameterValue("txtAccountNumber", rs.Fields("Company_AccountNumber"));
}
//...................
rsCompany = new ADODB.Recordset();
rsCompany.Open("SELECT * FROM Customer Where CustomerID = " + id, cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
Report.Database.Tables(2).SetDataSource(rsCompany);
rsTransaction = new ADODB.Recordset();
//changed for OPEN ITEM
//rsTransaction.Open "SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_Reference, CustomerTransaction.CustomerTransaction_PersonName," & _
//.........这里部分代码省略.........
示例15: CustomerStatement
private void CustomerStatement(ref int id)
{
ADODB.Recordset rsInterest = default(ADODB.Recordset);
ADODB.Recordset rsTransaction = default(ADODB.Recordset);
ADODB.Recordset rsCompany = default(ADODB.Recordset);
int lNumber = 0;
string lAddress = null;
ADODB.Recordset rs = new ADODB.Recordset();
string sql = null;
//Dim Report As New cryCustomerStatement
CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
Report.Load("cryCustomerStatement.rpt");
System.DateTime lDate = default(System.DateTime);
rs = modRecordSet.getRS(ref "SELECT MonthEnd.MonthEnd_Date From MonthEnd WHERE (((MonthEnd.MonthEndID)=" + gMonth + "));");
//rs.Open "SELECT MonthEnd.MonthEnd_Date From MonthEnd WHERE (((MonthEnd.MonthEndID)=" & gMonth & "));", cnnDBStatement, adOpenStatic, adLockReadOnly, adCmdText
//Report.txtStatementDate.SetText Format(rs("MonthEnd_Date"), "dd mmm yyyy")
Report.SetParameterValue("txtStatementDate", Strings.Format(DateAndTime.Today, "dd mmm yyyy"));
lDate = rs.Fields("MonthEnd_Date").Value;
rs.Close();
rs = modRecordSet.getRS(ref "SELECT * FROM Company");
lDate = System.Date.FromOADate(lDate.ToOADate() + 10);
lDate = DateAndTime.DateSerial(DateAndTime.Year(lDate), DateAndTime.Month(lDate), 1);
lDate = System.Date.FromOADate(lDate + rs.Fields("Company_PaymentDay").Value - 1);
//Report.txtPaymentDate.SetText Format(lDate, "dd mmm yyyy")
lAddress = Strings.Replace(rs.Fields("Company_PhysicalAddress").Value, Constants.vbCrLf, ", ");
if (Strings.Right(lAddress, 2) == ", ") {
lAddress = Strings.Left(lAddress, Strings.Len(lAddress) - 2);
}
Report.Database.Tables(1).SetDataSource(rs);
Report.SetParameterValue("txtAddress", lAddress);
lNumber = "";
if (!string.IsNullOrEmpty(rs.Fields("Company_Telephone").Value))
lNumber = lNumber + "Tel: " + rs.Fields("Company_Telephone").Value;
if (!string.IsNullOrEmpty(rs.Fields("Company_Fax").Value)) {
if (!string.IsNullOrEmpty(lNumber))
lNumber = lNumber + " / ";
lNumber = lNumber + "Fax: " + rs.Fields("Company_Fax").Value;
}
if (!string.IsNullOrEmpty(rs.Fields("Company_Email").Value)) {
if (!string.IsNullOrEmpty(lNumber))
lNumber = lNumber + " / ";
lNumber = lNumber + "Email: " + rs.Fields("Company_Email").Value;
}
Report.SetParameterValue("txtNumbers", lNumber);
//New banking details
if (Information.IsDBNull(rs.Fields("Company_BankName").Value)) {
} else {
Report.SetParameterValue("txtBankName", rs.Fields("Company_BankName"));
}
if (Information.IsDBNull(rs.Fields("Company_BranchName").Value)) {
} else {
Report.SetParameterValue("txtBranchName", rs.Fields("Company_BranchName"));
}
if (Information.IsDBNull(rs.Fields("Company_BranchCode").Value)) {
} else {
Report.SetParameterValue("txtBranchCode", rs.Fields("Company_BranchCode"));
}
if (Information.IsDBNull(rs.Fields("Company_AccountNumber").Value)) {
} else {
Report.SetParameterValue("txtAccountNumber", rs.Fields("Company_AccountNumber"));
}
//...................
rsCompany = new ADODB.Recordset();
rsCompany.Open("SELECT * FROM Customer Where CustomerID = " + id, cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
Report.Database.Tables(2).SetDataSource(rsCompany);
rsTransaction = new ADODB.Recordset();
//rsTransaction.Open "SELECT CustomerTransaction.*, TransactionType.TransactionType_Name, IIf([CustomerTransaction_Amount]>0,[CustomerTransaction_Amount],Null) AS debit, IIf([CustomerTransaction_Amount]<0,[CustomerTransaction_Amount],Null) AS credit FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" & id & "));", cnnDBStatement, adOpenStatic, adLockReadOnly, adCmdText
rsTransaction.Open("SELECT CustomerTransaction.CustomerTransactionID, CustomerTransaction.CustomerTransaction_CustomerID, CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_DayEndID, CustomerTransaction.CustomerTransaction_MonthEndID, CustomerTransaction.CustomerTransaction_ReferenceID, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_Description, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_Reference, CustomerTransaction.CustomerTransaction_PersonName," + " TransactionType.TransactionType_Name, IIf([CustomerTransaction_Amount]>0,[CustomerTransaction_Amount],Null) AS debit, IIf([CustomerTransaction_Amount]<0,[CustomerTransaction_Amount],Null) AS credit FROM CustomerTransaction INNER JOIN TransactionType ON CustomerTransaction.CustomerTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((CustomerTransaction.CustomerTransaction_CustomerID)=" + id + "));", cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
//Report.Database.Tables(3).SetDataSource rsTransaction, 3
if (rsTransaction.BOF | rsTransaction.EOF) {
rsTransaction = new ADODB.Recordset();
rsTransaction.Open("SELECT 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0," + " 0, 0 AS debit, 0 AS credit;", cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
Report.Database.Tables(3).SetDataSource(rsTransaction);
//Exit Sub
} else {
Report.Database.Tables(3).SetDataSource(rsTransaction);
}
if (rsTransaction.BOF | rsTransaction.EOF) {
return;
}
rsInterest = new ADODB.Recordset();
rsInterest.Open("SELECT * FROM Interest WHERE (((CustomerID)=" + id + ")) and (Debit>0);", cnnDBStatement, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
//If rsInterest.BOF Or rsInterest.EOF Then
if (rsInterest.RecordCount > 0) {
//Report.Field20.Top = 280
//Report.Field21.Top = 280
//Report.Field22.Top = 280
//Report.Field23.Top = 280
//.........这里部分代码省略.........