|
I am currently working on a system that uses an Access database to store a list of url's waiting to be processed. I need to be able to add to, and amend the database, and so, I have derived a class from the CRecordset class called CURLRecordset using the classwizard.
In my application, I can succesfully open a CDatabase object in order to connect to the database, but when it comes to opening the actual recordsets associated with it:
/*
CURLRecordset* unparsed_urls;
CDatabase* db;
CString sql;
*/
unparsed_urls = new ( CUnparsed ) ( db );
sql.Format ( "SELECT * FROM urls WHERE status = %d;", STATUS_NOT_CRAWLED );
unparsed_urls->Open ( CRecordset::snapshot, (LPCTSTR)sql );
I get the following exception:
"Invalid character value for cast specification on column number 2 (urladdress)"
I have traced the source of the exception to the final move() function call in the CRecordset class, but I have no idea how to deal with it. My database schema is as follows:
TABLE urls =
(
long urlid (PRIMARY KEY)
VARCHAR(256) urladdress
long status
long level
long keywordid
long sourceid
)
The header file for the CURLRecordset class is as follows:
class CURLRecordset : public CRecordset
{
public:
CURLRecordset(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(CURLRecordset)
// Field/Param Data
//{{AFX_FIELD(CURLRecordset, CRecordset)
long m_keywordid;
long m_level;
long m_sourceid;
long m_status;
CString m_urladdress;
long m_urlid;
//}}AFX_FIELD
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CURLRecordset)
public:
virtual CString GetDefaultConnect(); // Default connection string
virtual CString GetDefaultSQL(); // Default SQL for Recordset
virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support
//}}AFX_VIRTUAL
// Implementation
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
};
Any help will be greatly appreciated!
|
|
|
|
|
I made a Visual C++ application that uses ADO to query a database, and to update the changes.
I send some simple SQL statement to the database (an Access DB until now), like SELECT, UPDATE, etc.
Now I would like to make this through the internet.
I mean I run my program on my computer and it query the database that instead is on another computer, and it connects to it via tha Internet.
Where I can find a guide on how to do it?
Thankyou.
P.S.
I also think that I will need to use SQL Server or Oracle to store my database remotely, ad than use this server. Are there any service that offers this kind of hosting for free, so that I can start experimenting, without the hassle of installing my own SQL Server or ORACLE ?
Thank you very much.
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
First, yes you can query a database on another server across the wild web. This is done quite simply actually here is a DNSless connection string to a SQL Server
"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=pubs;Data Source=127.0.0.1;Use Procedure for Prepare=0"
You then change the IP addy in the Data Source attribute to point to the intended server. I've left a lot of details out here as to how it works etc. I recommend you do some studing in that area, but this should get you rolling .
Good Luck
![Smile | :)](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Hi.
After added a record into a Recordset(offline),how to access the new added record?
Scratch
|
|
|
|
|
If you move your cursor from added record(i.e MoveNext() ),then it will be available and you have access to it.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
When use VB your advice is work very well,while using VC++ this seem does not work.
Scratch
|
|
|
|
|
What is your cursor type?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I have seen the newest .NET show on the web recently and it introduced the ORM (Object Role Modeling). I think that this is a very good approach in order to build Object Orientated Models. Is there some kind of possibility to generate C# code stubs out of the ORMs yet. I think that this is the very missing stone in the whole idea. If we think further the information stored within the ORM would allow generating some kind of a Ralational-Object Mapper code including simple SQL. So if you changed your ER Model or add some new “Facts” you would just generate your ALTER-nation statements for the DB and generate new C# classes including the update of the Relational - Object mapping. Don’t you thing that this is actually the future of how applications will be created?
So long
Pawel
|
|
|
|
|
I have a fundamental question about
the way .NET handles the object orientated way of
persistence. I am coming from JAVA and WebObjects (Apple)
World and I am looking for a convenient way of working
with objects without seeing any SQL statements only
objects. I have used that approach for years on the
WebObjects Platform (Enterprise Object Framework) and in
Java recently (Container Managed Persistence). I am
looking for something like that in the Microsoft world.
As far as I understand Microsoft does not distinguish
between the Object Model and the Relational Model. The
main difference is that the Object model allows n : m
relationships and the Relational does not allow them. Here
a small example to visualize the problem:
Example:
There is a Patient object with following Attributes
String patientGUID;
String name;
Int age;
Hashtable diseases; (or some other Container like
Collection or Array)
And there is a Disease Object
String diseaseGUID;
String name;
In the object Model there is relation between Patient and
Disease where the patient has his diseases but on the
other site one disease can belong to 1..* patients. (n :
m)
That n : m relationship can not exist within a relational
database without a link table that contains the
connections between the tables: Patient and Disease.
Now, I would like to connect the object Model containing
TWO Entities (Patient, Disease) with the relational
database (containing THREE tables). Then I want to work
with my objects; e.g. create new diseases connect them to
existing patients by putting the diseases into the array
or create new Patients and connect them with already
existing diseases or just change a Patients name. When I
am finished I just want to say SAVECHANGES and the
database is updated accordingly including all link table
entries.
So all I have to care about are my objects and the
relations between them, some invisible layer does all the
dirty work like building SQL, converting the data types
and caching. So if I fetch a Patient with a specified GUID
I do not have to care about fetching his diseases. They
are fetched automatically. If there are too many Diseases
I do not care some kind of algorithm handles that problem
in such a way that if I have to search all of them for
something they are simply there. They are loaded on demand
(lazy evaluation)
Supposing that the disease has a further connection with
some DiseaseType Object/Table and that table has an
attribute/column "Description" I can access it by typing
the following code:
TextField1.Text = currentDisease.type().description()
Please note that to retrieve the description value I did
only fetch the Patient. The diseases and its types were
fetched automatically.
Is something like that possible or am I excepting too much
of the .NET?
Pawel
|
|
|
|
|
What you are talking about is not a .net feature per-say. What you are looking for is an application server (which is what WebObjects is).
.net can be used to develop an environment like you describe and once it is developed, you can do what you want. However, it does not remove the development aspect of back-end SQL calls, etc.
|
|
|
|
|
what I want is:
Object Role Modeling
see my other post!!
)))
Pawel
|
|
|
|
|
Hi,
I am learning C++ and have been doing pretty well until I got to this project I needed to complete. It's just a simple database, nothing fancy. I've imported msado15.dll, and have done eveything by the book but I keep getting this error upon executing the program that says "Data source name not found and no default drive specified. My instructor simply said that some people have an ODBC on thier systems and others don't. If I don't then I wont be able to get this to work. I'd like very much to concentrate on database building and design and was wondering if there is any way around this. I have WinXP Home editiion, and have just gotten (although not installed yet) pro. Any ideas would be appreciated.
I did set up my DSN and just now I did it again thinking that maybe something went wrong the last time. Any other ideas?? Please?
Thanks,
Garry
|
|
|
|
|
As posted on MSDN newsgroup:
Hello,
I think that we've stumbled accross a bug in CDO2000 which
causes a massive memory leak. This leaks happens on
Windows 2000 Professional. I failed to reproduce on
Windows 2000 Advanced Server.
Here is the code:
/////
IMessagePtr iMsg ;
iMsg.CreateInstance(__uuidof(Message)) ;
FieldsPtr Flds = iMsg->GetFields() ;
Flds->Item[cdoTo]->Value="james@drinkinginthesun.com";
/////
Is this a known issue? The leak will become obvious if the
above code is thrown into an infite loop. I have tested
this on Windows 2000 Professional with SP2 and Office 2000.
Thanks.
Regards,
James Pullicino
Response from MS:
James,
I see the leak you are reporting. This is apparently a leak in ADO (MDAC),
not CDOSYS. By removing the lines:
FieldsPtr Flds = iMsg->GetFields() ;
Flds->Item[cdoTo]->Value="james@drinkinginthesun.com";
and instead doing:
iMsg->To = "james@drinkingthesun.com";
I eliminated the leak.
Since you can't repro this on your Advanced Server, try comparing the
versions of MDAC on those machines...perhaps that is the difference?
Jason Johnston
Microsoft Developer Support - Messaging
Best Regards,
James Pullicino
Drinking In The Sun
Forgot Password?
|
|
|
|
|
Hi,
Is it posible to change a System DSN database path, runtime from a C++ application. Maybe with an API function or??
I have a alias to the System DSN, with this alias I can change the System DNS and by this change the MS Access database connected through the System DSN, but this meens that I need to create a new System DNS for every Access database I use under the application.
Thanks!!
Thomas Vanting
|
|
|
|
|
Is it necesary to create a System DNS entry for your app, maybe it would be more usefull to create it "on the fly", so you wont have to depend on that fixed path
|
|
|
|
|
Hi!
I have a project in MFC.In this project i use connection to the Access database (ODBC) and in Windows95 i have a problemm.When i try to connect to database,I recieve the message that driver does not support this function.
i try to install DCOM95 for Windows95
and then Jet40Sp3_Comp for working with Microsoft Access
database (ODBC) from MFC.But during instalation i recieve the
message that Error creating process D:\Win95
\System\odbcconf.exe /e/f
D:\Win95\System\jetodbc.rsp Reason:The system can not find the
file specified.
Tell me,please,is it possible to connect to database with ODBC in Windows95,and if it is possible,what i must do,what drivers or files i must add?!
Thanks,Irina.
|
|
|
|
|
Maybe If you install new version of MDAC it will be ok.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Hello all.
With ASP/ADO I tried query the Indexing Server of WIndows 2000 server and extract with success many usefull information about files, like Author,Company,Comments,Version ecc. ecc.
Now, how can do this with ADO.NET/ASP.NET.
I have to use a OleDb Provider?
Thanks in advance.
Sergio Bertini
|
|
|
|
|
|
Hi!
I can't build with VC++ 7.0 the project that use DAO. The VC++ 6.0 build correctly the same project. I receive the following error message:
fatal error LNK1120: 1 unresolved externals
"public: class ATL::CStringT > > __thiscall CdbLastOLEError::GetDescription(void)"
Do you now somebody the resolution?
Thanks
Feri
|
|
|
|
|
I have a consumer template like:
[
db_command(L"{ ? = CALL dbo.MyProcedure(?) }")
]
class MyProcedure
{
...
[ db_param(1, DBPARAMIO_OUTPUT) ] LONG m_RETURN_VALUE;
[ db_param(2, DBPARAMIO_INPUT) ] LONG m_id;
void GetRowsetProperties(CDBPropSet* pPropSet)
{
pPropSet->AddProperty(DBPROP_CANFETCHBACKWARDS, true, DBPROPOPTIONS_OPTIONAL);
pPropSet->AddProperty(DBPROP_CANSCROLLBACKWARDS, true, DBPROPOPTIONS_OPTIONAL);
}
};
And when I use it I do:
storedproc.m_id = someValue;
HRESULT hr = storedproc.Open(session);
hr = storedproc.MoveFirst();
if(hr == S_OK && storedproc.m_RETURN_VALUE == 0)
doSomething();
else
reportBloodyFailure();
It does not work! MoveFirst returns S_OK, the data from the rowset is in the accessor, but the darn return value is not valid! it's 0xcccccccc which looks an awful lot like uninitialized stack memory... The only two valid return values from this function is 0 or 2 (where 2 is an error code).
Is there anything special I have to do to actually get the return code?
Sonorked as well: 100.13197 jorgen
FreeBSD is sexy.
|
|
|
|
|
hey, I have a ms access file that stores when an entry was made. if that date field is today, i want to store it in a recordset object. how do i query that?
"SELECT CheckDate WHERE Checkdate = ???? TO ???? "
how would that work??? Please help! Thanks a bunch!
~Timothy T. Rymer
http://tim.xpertz.com
http://www.digipen.edu
http://www.ttrx.com
|
|
|
|
|
SELECT CheckDate WHERE CheckDate BETWEEN #??/??/??# AND #??/??/??# should do it.
|
|
|
|
|
Ed Gadziemski wrote:
SELECT CheckDate WHERE CheckDate BETWEEN #??/??/??# AND #??/??/??# should do it.
Thanks! I live and learn. Being doing it the hard way all this time
FEI: for SQL users replace the hash/pound, #, with a single quote, '. e.g. SELECT CheckDate WHERE CheckDate BETWEEN '??/??/??' AND '??/??/??'
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Tim Smith wrote:
Over here in the third world of humor (a.k.a. BBC America),
peterchen wrote:
We should petition microsoft to a "target=_Paul" attribute.
|
|
|
|
|
Greetings,
Is there a way to get the names of the keys that each table has in ADO? I just want to display a each table's keys so that the user can see what keys are available.
Thanks in advance!
|
|
|
|