|
I would really like to see all the code (possibly a small article) to see exactly what you are doing. Have you read Nish and Rama's co-article yet with a slew comparison on different Microsoft languages? If not I would highly recommend reading it.
A statistical analysis of the performance variations of assorted managed and unmanaged languages [^]
Nick Parker
If the automobile had followed the same development as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year killing everyone inside.
-Robert Cringely
|
|
|
|
|
He is all of the code... It assumes that there exists an Access db at c:\test.mdb and a SQL db called testSQL on an instance at COMPUTER\SQLServer... The dbs each contain one table named Test, defined by one Date field (Observation) and 40 Single fields (Val1, Val2, ...). The project has a reference to DAO 3.6 Object Library...
Imports System.Data.OleDb
Imports System.Data.SqlClient
Module Module1
Sub Main()
Randomize(-1000)
Dim start As Date = Date.Now
ExecuteDAO()
System.Console.WriteLine("DAO output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
start = Date.Now
ExecuteOleDb()
System.Console.WriteLine("OleDb output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
start = Date.Now
ExecuteSql()
System.Console.WriteLine("Sql output took " & DateDiff(DateInterval.Second, start, Date.Now) & " seconds.")
System.Console.WriteLine("Press any key to continue...")
System.Console.Read()
End Sub
Public Function ExecuteOleDb()
Dim conn As OleDbConnection
Dim cmd As IDbCommand
Dim i, j As Integer
conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source='c:\test.mdb'")
conn.Open()
cmd = CreateCommand(conn)
For i = 1 To 8760
cmd.Parameters(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
For j = 1 To 40
cmd.Parameters(j).Value = Rnd()
Next
cmd.ExecuteNonQuery()
Next
conn.Close()
End Function
Public Function ExecuteSql()
Dim conn As SqlConnection
Dim cmd As IDbCommand
Dim i, j As Integer
conn = New SqlConnection("Data Source=COMPUTER\SQLServer; Database=testSQL; Integrated Security=SSPI")
conn.Open()
cmd = CreateCommand(conn)
For i = 1 To 8760
cmd.Parameters(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
For j = 1 To 40
cmd.Parameters(j).Value = Rnd()
Next
cmd.ExecuteNonQuery()
Next
conn.Close()
End Function
Public Function ExecuteDAO()
Dim dbEng As DAO.DBEngineClass = New DAO.DBEngineClass()
Dim wk As DAO.Workspace = dbEng.Workspaces(0)
Dim db As DAO.Database = wk.OpenDatabase("C:\test.mdb")
Dim rs As DAO.Recordset = db.OpenRecordset("Test")
Dim i, j As Integer
For i = 1 To 8760
rs.AddNew()
rs.Fields(0).Value = New Date(2002, 1, 1).AddHours(i - 1)
For j = 1 To 40
rs.Fields(j).Value = Rnd()
Next
rs.Update()
Next
rs.Close()
db.Close()
End Function
Public Function CreateCommand(ByVal conn As IDbConnection) As IDbCommand
Dim cmd As IDbCommand = conn.CreateCommand()
Dim param As IDbDataParameter
param = cmd.CreateParameter()
param.ParameterName = "@obs"
param.DbType = DbType.DateTime
cmd.Parameters.Add(param)
Dim cmdText As String = "INSERT INTO Test (Observation"
Dim cmdTextParams As String = "@obs"
Dim scen As Integer
For scen = 1 To 40
param = cmd.CreateParameter()
param.ParameterName = "@val" & scen
param.DbType = DbType.Double
cmd.Parameters.Add(param)
cmdText &= ", Val" & scen
cmdTextParams &= ", @val" & scen
Next
cmdText &= ") VALUES (" & cmdTextParams & ")"
cmd.CommandText = cmdText
cmd.Prepare()
Return cmd
End Function
End Module
|
|
|
|
|
I am using InstallShield Developer 7.04 in order to distribute my application. My application is a maintenance application based on MSAccess. Now I want to delete some rows and add some others in one table. Can that be done using InstallShield and if yes how?
Thanks,
Spiros Prantalos
|
|
|
|
|
I don't know if you can call ADO from Installshield script, but you could certainly create a COM object to do your maintenence and then call that from InstallShield.
Dave.
|
|
|
|
|
Ok. That is great!! Assuming that I create a com object to update my database do I have to create a spcial script function in installscript that will call this component?
Thank you very much. Now I can a light at the end of the tunnel
Spiros Prantalos
|
|
|
|
|
If you're using ISD 7 (Basic MSI Project, as opposed to Standard Project) then why don't you create a custom action that runs an MSI DLL - that can do pretty much anything.
You just need a DLL that exports a function in the format
__declspec(dllexport) UINT APIENTRY MyFunction(MSIHANDLE hMSI) Inside that you can call anything you could normally call from C++, including the Windows Installer API (if you need to pass any properties in).
Paul
|
|
|
|
|
Are there any classes or libraries in C# help me to list all available OLE DB providers in my system?
Are there any requirements to do this work?
Thanks for your help.
|
|
|
|
|
Hey everyone,
I have an app which uses an access database for data storage. I access the app using ADO which has all worked fine in the past. Anyway, I just tried to run the app on a WinXP machine but it doesn't work. I can connect to the DB fine but when I do a "SELECT * FROM FILES" I get the following error
CADORecordset Error
Code = 80040e37
Code meaning = IDispatch error #3127
Source = Microsoft OLE DB Provider for ODBC Drivers
Description = [Microsoft][ODBC Microsoft Access Driver]
The Microsoft Jet database engine cannot find the input table or query 'FILES'.
Make sure it exists and that its name is spelled correctly
However, I can open this database from within access OK and I can also get into the FILES table through an ASP page using the same connect string I use in my app.
The WinXP machine is using the latest MDAC (2.7 refresh) and I have updated the JET drivers to sp6.
Anyone have any clues?
Cheers
James
|
|
|
|
|
Does it happen when accessing other tables?
Any chance "FILES" is a keyword in Access?
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
Guess, what? It wasn't opening the DB I thought it was. It was opening an earlier version in a different path .
Thanks for the help though.
Cheers
James
|
|
|
|
|
Hi all,
I see that the OLEDBProviderInfos can list all available OLE DB providers. But you must install MS SQL to use Microsoft DTSPackage Object Library.
Are there any other way to do this work?
|
|
|
|
|
I have a problem. A program on a computer issues a query with a date in it to another computer that runs SQL Server. The problem is that the client computer has a different locale than the server computer.
Is there a way to get the SQL server locale from the client so a properly formatted query can be sent.
Tx
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
The simplest answer is to format the date as an ODBC timestamp:
{ts 'yyyy-mm-dd hh:nn:ss'}
|
|
|
|
|
Please, give me some advice.
I need the way to search in the html-documents that are stored as images.
The way to convert an image to text or ntext would also help.
I've tried to use full-text search engine, but it does not work with Russian and Ukrainian texts or maybe I've just configured it wrong
Thank you in advance
Archi
|
|
|
|
|
Hi,
I have to access a SQL database with multiple tables and round about 1.6 million entries. The client is written in C++ and accesses the database through the ADO interface.
At clients' startup I need to read in all existing records using 'SELECT * FROM Table'. I have encountered one problem depending on the operating system the client is running on. On Windows 2000 and Windows XP everything is fine, all the records gets loaded without any error.
However, on Windows NT 4.0 Workstation (Service Pack 6a installed), I get the following ADO error while retrieving the records:
'-2147217915 (0x80040e05) An object was open.'
Since I was not able to find any kind of further information on the internet yet, I would appreciate if anybody could help me out with this - at least explaining the mentioned error description.
Regards,
am_
|
|
|
|
|
You really need to design your db or your client app a bit better.
select * on a table with 1.6 million records is never a good idea.
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
Well...I do know that. Problem is that I have no influence on the design of the database since it is given by my customer.
Same applies to the design of the client more or less. I have to 'convert' the records for faster lookup therefore I need to do the mentioned query.
Nevertheless that should not raise the described error message. Anyway, thanks for your help.
Regards,
am_
|
|
|
|
|
paste your code if u want more help with that specific error then!
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
The following is an extract of the code I am using:
BSTR g_bstrEmpty = ::SysAllocString(T2OLE(""));
CString DatabasePath("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=SERVER_NAME");
ADOConnection *pIDBCon = 0;
ADORecordset *pIRecordset = 0;
HRESULT hr = CoCreateInstance(CLSID_CADOConnection,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADOConnection,
static_cast<LPVOID *>(&pIDBCon));
if(SUCCEEDED(hr))
{
BSTR bstrConnection = DatabasePath.AllocSysString();
pIDBCon->put_ConnectionString(bstrConnection);
hr = pIDBCon->Open(g_bstrEmpty, g_bstrEmpty, g_bstrEmpty, -1);
if(SUCCEEDED(hr))
{
hr = pIDBCon->put_CursorLocation(adUseClient);
hr = CoCreateInstance(CLSID_CADORecordset,
NULL,
CLSCTX_INPROC_SERVER,
IID_IADORecordset,
static_cast<LPVOID *>(&pIRecordset));
if(SUCCEEDED(hr))
{
hr = pIRecordset->putref_ActiveConnection(pIDBCon);
VARIANT g_varEmpty;
g_varEmpty.vt = VT_ERROR;
g_varEmpty.scode = DISP_E_PARAMNOTFOUND;
COleVariant varSQL("SELECT * FROM Table");
hr = pIRecordset->Open(varSQL, g_varEmpty, adOpenKeyset, adLockOptimistic, adCmdText);
pIRecordSet->Close();
}
}
pIDBCon->Close();
}
I am using a customer defined wrapper class which just adds another layer to the ADO stuff...the above things are basically what is happening... The 'Open' call on the recordset object fails with the mentioned error.
Edited: Added missing declaration of 'g_varEmpty'
Regards,
am_
|
|
|
|
|
Hi am_
Yes, I am familiar with the ADO way of doing this.
My fault, I should have specified that I am using ADO.NET as you will see from higher up in the thread.
So, I have this problem in the context of ADO.NET
Thanx
Doug
Doug
|
|
|
|
|
Hi there
This should be simple to fix - unfortunately I seem to just be missing something
My ASP page sends through something like 16/09/2002, I recieve it as a varchar. I then need to convert to datetime, and use it with another date to select records for a statement.
I have tried the following:
set @in_start_date = convert(datetime, @in_start_date)
set @in_start_date = convert(datetime, @in_start_date,109)
set @in_start_date = CAST(@in_start_date AS datetime)
All 3 give me a date, but also a message saying:
Server: Msg 242, Level 16, State 3, Line 12
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Because of the out of range datetime value my stored procedure can't work with the date values & pass the results back to the crystal report.
How do you guys convert varchar dates with "/" separating dd/mm/yyyy to datetime format? Thanks very much
The following statement about your geekness is true. The previous statement about your geekness is not true.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT/P d- s: a- C++++$ UL+>++++ P+ L++$ E- W+++$ N !o K+ w++$ O---- M--
PS- PE Y+ PGP--- t !5 X- tv b+++ DI++ D+ G++ e++>e+++ h--- r+++
------END GEEK CODE BLOCK------
|
|
|
|
|
Using ASP and SQL mixed gives tonnes of problems with dateformat. Largely becayse america use MM-DD-YYYY and the rest of the world use the more logical DD-MM-YYYY.
I get round the problem by doing the following:-
1. throughout my asp application, I always use the DD-MM-YYYY dateformat.
2. When passing a date to SQL, i send a string from this function:-
Function GetSQLDate ( dtDate)
' check dtDate is a Variant->Date type
If Not IsDate(dtDate) then
Err.Raise vbObjectError + 1024, "Global::Function::GetSQLDate","Argument not a date"
End If
Dim dpYear, dpMonth, dpDay, dpHour, dpMinute, dpSecond
dpYear=Year(CDate(dtDate))
dpMonth=Month(CDate(dtDate))
dpDay=Day(CDate(dtDate))
dpHour=Hour(CDate(dtDate))
dpMinute=Minute(CDate(dtDate))
dpSecond=Second(CDate(dtDate))
if Not Len(dpYear) = 4 then dpYear="20" & dpYear
if Not Len(dpMonth) = 2 then dpMonth = "0" & dpMonth
if Not Len(dpDay) = 2 then dpDay = "0" & dpDay
if Not Len(dpHour) = 2 then dpHour = "0" & dpHour
if Not Len(dpMinute) = 2 then dpMinute = "0" & dpMinute
if Not Len(dpSecond) = 2 then dpSecond = "0" & dpSecond
GetSQLDate=dpYear & "-" & dpMonth & "-" & dpDay & " " & dpHour & ":" & dpMinute & ":" & dpSecond
End Function
This puts the date for sql in an almost foolproof dateformat.
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
Try:
SET @in_start_date = CONVERT(datetime, @in_start_date, 103)
|
|
|
|
|
I have an app that uses DAO to Access 97 databases that are replicated. Periodically, when the app is shutdown and then restarted I get an error message for "no current record". It gets resolved when the replication is run manually, the replication is deleted and rebuilt, or worse case the replication is deleted and the design master redesignated. Anyone have a clue on how to track this issue down?
|
|
|
|
|
FWIW, I am expriencing a problem similar to the one documented in MS KB Article #Q218751[^], although I am using OleDB classes from within VC++ 6.0.
If I try to call a stored procedure that takes a BLOB parameter as input, and returns an OUTPUT parameter, the output parameter does not get set correctly (in fact, it is not touched at all!) if the length of the BLOB is greater than ~8000 bytes. Manually truncating the BLOB before calling the SP causes the problem to go away. This is with using the MSDASQL driver.
Just a brief warning to those that might be using MDAC 2.7 with OleDB/ADO ...
Peace!
-=- James (Sonork:100.21837)
"There is nothing worse than being oblivious to the fact that you do not know what you are doing."
[Get Check Favorites 1.4 Now!]
|
|
|
|