|
Yeah, I've downloaded one and had a try.
thank u for your kind recommendation.
By the way, it seems also great in connecting with all kinds of databases.
|
|
|
|
|
Who can help me with the following:
I have a database with a column Begin_date. When I use the statement Select * From ...... Where Begin_date (hours, -8, GetDATE ) i get a error. The problem is that My ASP server ( PWS in Win98 ) doesn't reconize getDATE. Who can help me with this problem!? Can you give me a working example?
Example:
I want to show all records from the column Begin_date that 8 ours before the date and time is reached. So if I have a record with: 06-05-2001 20:00 then it must be shown on 06-05-2001 12:00
It also have to stay shown until it is deleted. Who now's a asp code that make's this work.
Greeetings from holland,
Jan Pieter
Jan Pieter Elenbaas, Student in Holland.
|
|
|
|
|
I'm not exactly sure what you're asking, but if you're getting dates back from the database and want to display the date, only 8 hours earlier it would look something like this:
Dim datBeginDate
Do Until rs.EOF
datBeginDate = DateAdd("h", -8, rs("Begin_Date"))
Response.Write "Begin Date - 8 Hours: " & datBeginDate & "<BR>"
Loop
You could do all that without the variable, I thought it would be easier to understand with a variable.
If you're having trouble with that code try this code in an ASP page:
Response.Write "Eight hours ago, it was " & DateAdd("h", -8, Now)
|
|
|
|
|
I've found 3 different ways of doing ADO in VC++.
1) The most common way seems to be doing an #import on the ado15.dll
This generates smart pointers to all the objects and off you go.
2) I've also seen used: Import the desired classes from ado15.dll as a typelib,
using the class wizard which generates a truckload of COleDispatch wrapper
classes.
3) Raw COM: Do CoCreateInstance on the interfaces using CLSID's built from the "ADODB.Whatever" type string.
The problem I have with 1) #import is that a class that is both a pointer and not a pointer (-> and .) makes me shudder. I know, it's only overloaded operators, but still....
The REAL problem I have with #import is with _bstr_t. I find that CComBSTR is a much better class if I'm going to also be converting to and from CString's , but the #import smartpointers force me to use _bstr_t's.
The problem I have with 2) COleDispatch generated classes is all those classes I have to have in my project. I get dizzy looking at the class view.
So I decided on method 3). So far I've had good luck with it. The only 'disadvantage' is that I'm responsible for doing all the housecleaning. (This might be a good thing). CComBSTR works great with this approach , and a pointer is a pointer is a pointer (No smartpointer operator goofiness). All the interfaces are defined outside of my project so I don't have to have them in my class view.
Does anyone know any GOTCHA!'s that I might run into using raw COM approach?
(Or perhaps any alternate methods).
Thanks,
Chrys.
|
|
|
|
|
I suggest doing #1, but use the Visual C++ extensions for ADO to avoid the BSTR stuff.
A small sample can be found here: www.gl.umbc.edu/~bcorfm1/software.html
|
|
|
|
|
Hi there,
I was wondering if SQL Server gives it users the option to decrypt an encrypted stored procedure?
If a stored procedure is created with "WITH ENCRYPTION" option, is there anyway, that anyone can open it and view it in text mode?
thanks
|
|
|
|
|
The problem is. I have installed version of MS SQL Server 7.0 - Desktop Edition. And I have to import some data in a new, just created database. So when I try to use the DTS Wizard, at the end of the dialog, appears a protection error message. Something like mms error. What that means. What do I have to do. It's really urgent!!!
|
|
|
|
|
I have developed a application by Visual C++ 6.0, in which I have use ADO and OLE provider to access a database(For example:temp.mdb),some codes as following:
...
_ConnectionPtr pCon;
CString strcnn("Provider=Microsoft.Jet.OleDB.4.0;Data Source=temp.mdb");
pCon->Open(strcnn,"","",NULL);
...
When I do debuging, Application can access Database well, but When I want to
deploy application , I try to intall on Windows 98, While I start application from Start/Program/xxx
application failed to access database (temp.mdb), What can I do?
All suggestion will be welcome, thanks.
contact me at kebinlu@hotmail.com, thanks
|
|
|
|
|
I want to add column in Data Grid control... The DataSource is from ADO.... I can display
all the columns if i did not set the the columns.... If i set the columns i can only set 2
columns.. How to increase the columns so that i can display more than 2 column and format
the columns...
URGENT!!!!!!
THANX!!!!!
|
|
|
|
|
Wouldn't you just write a SQL query to display only the columns that you wanted in your DataGrid? There's no reason to format them yourself; the DataGrid does this for you.
|
|
|
|
|
Hello everybody,
Can we databases of Access or SQL Server programmitically using ADO thru VC++, if we can please give the code snippet.
Thanx in advance
|
|
|
|
|
try to use ADOX object.
you will find solution.
|
|
|
|
|
Hello,
when i import msado15.dll i do not get _RecordsetPtr. I can use _Recordset but i do not know how to get item data. i found in the samples the code but it always uses _RecordsetPtr.
how can i get _RecordsetPtr ? or what is eqivalent usage of _Recordset to the _RecordsetPtr's call:
_RecordsetPtr Rs1;variant = Rs1->Fields->GetItem (_variant_t ("name"))->Value;
thank you
PS I use:
#import "c:\program files\common files\system\ado\msado15.dll" \
no_namespace rename "EOF", "getEOF");
_COM_SMARTPTR_TYPEDEF(_Recordset, __uuidof(Recordset));
|
|
|
|
|
Well i've been using _RecordsetPtr as a member in header files. I had a quick look at one of my sources and this is everything that I include, so it's probably in one of these.
Good luck, Robert Dickenson.
/*
#include "stdafx.h" // stdafx only includes the following two:
*/
#include <atlbase.h>
#include <atlcom.h>
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
#include <ole2.h>
#include <oledb.h>
#include <icrsint.h>
|
|
|
|
|
...if you'll excuse the topic line ...
what a day- sifted through miles of docs, to still be stuck on this one:
I have a stored procedure sp_ProductRegionalDetails wich takes 2 arguments- @productID and @regionID. This will return a row containing the details of that product, localized (brand etc.) to that region. The thing is, if it does not find an entry for that region, it will search the wider 'parent' region of @regionID, and so-on. Works a treat.
I now need a rowset containing all of the products (their details) in a region. I have a column of distinct ProductIDs and a single RegionID. I need to call sp_ProductRegionDetails with each ProductID and the RegionID, and append the results somehow to the others...
Did I explain my problem..?
thanks for any help
Nick
|
|
|
|
|
yeah baby
|
|
|
|
|
Did you tried to use a temporary table or recursion? I am sorry that I cannot offer you more details since I don't know the specifics, but here is how I'd wrote it:
(1) Recursion. This assumes that your region table cannot find a loop (from a region parent you cannot get back to the same region parent).
Anyway, if this happens, select into a temporary table all the regions you can find starting with a parent, eliminate duplicates and you'll get a table containing the parent region candidates (either our passed ID or an ancestor), and also you can create another temporary table with all the details you need joining the #parents with #products (or @productID, if only a product interests you).
Create Procedure sp_ProductRegionalDetails
@productID int,
@regionID int
As
Declare @lRetVal int
Select @lRetVal = 1
Declare @fExitLoop Bit
Select @fExitLoop = 0
Declare @LoopProductID int
Declare @LoopRegionID int
Select @LoopProductID = @productID, @LoopRegionID = @regionID
While (@fExitLoop = 0)
Begin
Select [... Product regional details ...] From [... Tables, Joins ...] Where
ProductIdField = @LoopProductID And
RegionIdField = @LoopRegionID And
And [... additional conditions, etc ...]
If [The field interesting for me are retrieved]
Begin
Select @fExitLoop = 1
Select @lRetVal = 0
End
Else
Begin
Select @LoopRegionID = Exec sp_ParentRegion @LoopRegionID
If @LoopRegionID Is Null
Begin
Select @fExitLoop = 1
End
End
End
Return @lRetVal
(2) Temporary tables.
Create Procedure sp_ProductRegionalDetails
@productID int,
@regionID int
As
Declare @lRetVal int
Select @lRetVal = 1
[Create a temporary table containing all regions]
-- Create Table #regions (regionID int, ToSelect bit default(0) ) - for example
[Populate this table from our starting point: @regionID - the table will be populated in the natural order, i.e. starts with our regionID, if will find something then return, if not advance to the next parent etc.]
[Eliminate duplicated regionID]
[Query temporary table by joining with @productID]
[Retrieve results and mark in the temporary table ToSelect = 1 where informations you need were found]
[For the first entry in the temporary table with ToSelect = 1 get this row; this is our first row]
[If all the rows in temporary table have ToSelect = 0 --> no results found and return failure]
[If at least one row has ToSelect = 1, return the results associated with this regionID]
Return @lRetVal
If you need all the possible results, I suggest you to create (C++ mode) the temporary table from code, use in sp, read results after sp and drop tabel after. Something like:
VOID GetRegionInfo(DWORD *pdwResultCount, LP_PRODUCTRESULTS *ppResult)
{
CreateTemporaryTable(szTempTableName);
CallSP(szStoredProc, szSPName, pParams);
SelectResultsFromTemporaryTable(pdwResultCount, ppResult);
DropTemporaryTable(szTempTableName);
}
All the best,
Sardaukar
|
|
|
|
|
I'm very new to ADO... The problem I have is I can easily read an Access2000 database, but I can't write to it. I do an AddNew, then update the bound classes memver variables, and then call Update(). As soon as I call update, I get a crash. Please anyone got any ideas why? Here is the code it use...
<br />
_bstr_t strCnn(DSN_CONNECT_STRING);<br />
<br />
HRESULT hr = S_OK;<br />
IADORecordBinding *picRsPatient = NULL;
<br />
try<br />
{<br />
TESTHR(m_pConnection.CreateInstance(__uuidof(Connection)));<br />
m_pConnection->Open(strCnn,"","",adConnectUnspecified);<br />
<br />
TESTHR(m_pRstPatient.CreateInstance(__uuidof(Recordset)));<br />
m_pRstPatient->Open("Patient", <br />
_variant_t((IDispatch *)m_pConnection,true), adOpenKeyset,<br />
adLockOptimistic, adCmdTable);<br />
<br />
TESTHR(m_pRstPatient->QueryInterface(<br />
__uuidof(IADORecordBinding),(LPVOID*)&picRsPatient));<br />
TESTHR(picRsPatient->BindToRecordset(&m_rsPatient));<br />
<br />
}<br />
<br />
catch(_com_error &e)<br />
{<br />
PrintProviderError(m_pConnection);<br />
PrintComError(e);<br />
}<br />
<br />
m_pRstPatient->AddNew();<br />
strcpy(m_rsPatient.m_szPatientName, "James bond");<br />
strcpy(m_rsPatient.m_szPatientNumber, "007");<br />
m_pRstPatient->Update();<br />
<br />
if(m_pRstPatient)<br />
m_pRstPatient->Close();<br />
if(m_pConnection)<br />
m_pConnection->Close();<br />
Thanks
|
|
|
|
|
Cant Point out Exactly what the error is.I Had a similar error.
Check If the Database has any constraints in it(foreign etc).
Also check if recordset parameters are supported by the database.
|
|
|
|
|
I found what is was. The database was empty - it had no records in it at all. Supposedly you need a dummy record for it to work
|
|
|
|
|
I use VFP98 open a database named abc.dbf,only spend 5 second include show all the data in database.
But,when I use ODBC API open the abc.dbf,and show all the data ,It spend much more times,and
make the computer shutdown!!(There is not enough memory!!)
Thanks!
hi
|
|
|
|
|
how are you using the odbc stuff?
you posting doesnt give enough details to say much about what is causing the problems
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Sorry,the following is the detail!
Notice: The abc.dbf has 500 million records!!!!
The code is too long,I can only give you virtual code!(Using VC++ with ODBC API)
1.SQLDriverConnect(); //connect the database abc.dbf .
2.SQLSetStmtOption(...SQL_CURSOR_DYNAMIC);//Create a scrollable cursor.
3.SQLExecDirect(); //Execute SQL directly.(Select * from tablename)
4.SQLNumResultCols(); //Get selected column numbers.(The fields count)
5.SQLDescribeCol(); //Save column describe in an object array.
6.SQLBindCol(); //Bind every column(fields) with a variable which described in step 5.Saved in an object array.
7.SQLFetchScroll(...SQL_FETCH_LAST);//Move cursor to last record,to get selected records count!It related to step 6.
8.Use ListView show the records data which saved in an object array in setp 6.
Notice: whith the 500 million records.
Setp 1 to 6 spend a few second,but in step 7,it take much more time ,and make my
compter shutdown because there is not enough memory!
Thanks!
hi
|
|
|
|
|
Why can't you just use "select count(*) from ..." instead of traversing 500 million records?
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks!
You can resolve the record numbers of the table,but how to show every record data much more fast like VFP98.
In my way,I use SQLFetchScroll(...SQL_FETCH_NEXT) to get and show record data one by one,It takes much more time!I want to make it fast,how can I do?
hi
|
|
|
|
|