|
|
Can CDAORecordset (in VC6 or VC7) deal with Access 2000 or 2002 ?
or.. is this just an MDAC issue?
(DB newbie)
-c
ImgSource | CheeseWeasle
|
|
|
|
|
Sadly, not an MDAC only issue. The problem is that the MFC DAO support is hardcoded to load particular versions of DAO, and won't "automatically" use the latest version. There's an MSKB article on it (Q236991), which explains how to resolve it for apps that dynamically link to MFC, and a brief explanation of what to change for apps that static-link. (They advocate a full build of MFC, but I'm sure I've seen another workaround as well).
Steve S
|
|
|
|
|
Hello there i have a project which i want to run on windows o.s.
Now the only problem i am facing is that when i use the same
#import "G:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" rename("EOF", "ADOEOF")
using namespace ADODB;
i get an error and also i did a search on msado15.dll in windows 95 it was not there.
my connection string is like this.
TCHAR pAppPath[_MAX_PATH];
GetModuleFileName(NULL,pAppPath,_MAX_PATH);
// Trucating and attaching the mdb file path
CString csAppPath(pAppPath);
csAppPath = csAppPath.Left(csAppPath.ReverseFind( '\' ));
csAppPath+="\\BackUp.mdb";
// Adding other information to the mdb file
CString csConStr = "Driver={Microsoft Access Driver (*.mdb)};";
csConStr += "Dbq=";
csConStr += csAppPath;
csConStr+= ";Uid=;Pwd=;";
I could use jet ole db provider but the problem is the no driver or provider is present in windows 95 and 97.
After search on internet i found a solution about installing mdac and dcom95 and then running the thing and it worked but the redistribuatable was like 8 and 1.3 MBs which i don't want
somebody also told me to package my mdb with project and use jet engine i haven't looke at the redistributable for jet but it may be some MB'S.
The problem is there redistributables are heavy.
What i need is a simpler and smaller solution.
to using ado with msacces on windows95.
My second question is can we include just msado15.dll
without whole of the path coz system directory could be on any partition volume.
I need urget help regarding these two matters and i would be more than greatful for a viable solution
|
|
|
|
|
You could use DAO, rather than ADO, as it's lighter weight, but then you'll probably have to rewrite chunks of your code.
Your second question is easier. Using Tools/Options/Directories add the actual path of MSADO15.DLL into the INCLUDE section and use
#import <msado15.dll> rename("EOF","ADOEOF")
You need the path at compile time, not runtime, which does require that the components be installed, so you have no option to to install MDAC.
Steve S
|
|
|
|
|
Ok Using Tools/Options/Directories i added the directory path.
After that i did this
#import <msado15.dll> rename("EOF", "ADOEOF")
using namespace ADODB;
It works and doesn't give any error message now i would like to know one thing now if i take it to some pc where there is no msado15.dll would it work.
and also if its on a different path then the path i gave in the directory settings would it do.
And would there be no version conflict with already installed msado15.dll.
So there are three question which actually arose in my mind.
And i would also like to make clear what does these settings do, compile time settings do they bring in the msado15.dll into my project or what.
|
|
|
|
|
Ok Using Tools/Options/Directories i added the directory path.
After that i did this
#import <msado15.dll> rename("EOF", "ADOEOF")
using namespace ADODB;
It works and doesn't give any error message now i would like to know one thing now if i take it to some pc where there is no msado15.dll would it work.
and also if its on a different path then the path i gave in the directory settings would it do.
And would there be no version conflict with already installed msado15.dll.
So there are three question which actually arose in my mind.
And i would also like to make clear what does these settings do, compile time settings do they bring in the msado15.dll into my project or what.
I think i am getting somewhere with the help you provided. Thank you very much Steve.
|
|
|
|
|
1. If there's no MSADO15.DLL, it won't work; this is why MDAC 2.x needs to be installed.
2. If it's on a different path, it would work (since at runtime you're using the registry entries to locate stuff -- part of COM)
3. You won't ship MSADO15.DLL with your app.
What #import does is examine the type library of the specified file (in this case MSADO15.DLL) and it then generates .TLH and possibly .TLI files. These are compiler-generated, usually once in a project, and automatically pulled in when the source module (CPP or H file) is used by the compiler. These define the appropriate interface wrappers with methods etc, and normally include definitions for things like smart pointers using the CComPtr template.
It definitely does NOT pull in any DLLs into your app. The stuff it produces means that it's easier to work with COM objects in C++, almost as easy as with VB.
Hope this helps.
Steve S
|
|
|
|
|
I am going to be using msado15.dll is there any way i don't give the absolute path like given below.
#import "G:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" rename("EOF", "ADOEOF")
using namespace ADODB;
and just use
#import <msado15.dll>
or use #include "msado15.tlh"
or tlb any thing but without whole path.
And one main thing i would be using my project in any windows.
The whole of the path should not be given coz system directory could be on any partition volume.
c:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" rename("EOF", "ADOEOF")
using namespace ADODB;
I am going to include msado15 setting in stdafx.h.
Thanx in advance.
|
|
|
|
|
Hi
I have a windows form with textboxex liked to a dataset, using databindings, i din´t want that the user autoedit records, for another words i don´t want that the user write in a textbox directly without click in a button for "EditMode".
I tried the readonly and the enabled controls properties, but both change the control color and i don´t want that.
Someone have the same problem?
PB
|
|
|
|
|
the following is the ocde to accessa ms database using ADO..
the code connects it to the databse..but
how to display the output..
kindly help me in this regard..
#include<stdio.h>
#include<stdlib.h>
#include<iostream.h>
#include "STDAFX.H"
//#include "AFX.H"
#import "c:\program files\common files\system\ado\msado15.dll" rename("EOF", "EOFile")
struct StartOLEProcess
{
StartOLEProcess()
{
::CoInitialize(NULL);
}
~StartOLEProcess()
{
::CoUninitialize();
}
} _start_StartOLEProcess;
void main(void)
{
ADODB::_ConnectionPtr m_pConnection = NULL;
ADODB::_RecordsetPtr pRecordset = NULL;
//ADODB::FieldPtr pAuthor;
//_variant_t vAuthor;
//char sAuthor[40];
//HRESULT hr = S_OK;
VARIANT *vRecordsAffected = NULL;
char ConStr[500];
//VARIANT *vRecordsAffected = NULL;
//int ctr;
/*
printf("\nEnter Database Path and File name: ");
fgets(File, 250, stdin);
for (ctr = 0; (unsigned int)ctr < strlen(File); ctr++)
{
if (File[ctr] == '\n')
{
File[ctr] = '\0';
break;
}
}
ConStr[0] = '\0';
strcat(ConStr, "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=");
strcat(ConStr, File);
hr = con.CreateInstance(__uuidof(ADODB::Connection));
printf("\nCreateInstance result= %d uuidof= %d\n", hr, __uuidof(ADODB::Connection));
printf("\nConnection object created.");
con->Open(ConStr, "", "", 0);
// Create a Connection object and open it with mcb.krz, an access database
_ConnectionPtr m_pConnection; */
BOOL m_bIsConnectionOpen;
// Create an instance of _Connection
HRESULT hr ;
hr = m_pConnection.CreateInstance(__uuidof(ADODB::Connection));
cout << "Connection object created." ;
if (SUCCEEDED(hr))
{
//Open a connection where database is access database : "d:\mcb.krz"
//
/*
hr = m_pConnection->Open( _bstr_t(L"Provider=Microsoft.Jet.OLEDB.3.51);
Data Source= "c:\\emailparsing\\email_details.mdb;"), _bstr_t(L""), _bstr_t(L""),adModeUnknown);*/
ConStr[0] = '\0';
strcat(ConStr, "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=");
strcat(ConStr, "c:\\emailparsing\\email_details.mdb" );
m_pConnection->Open(ConStr, "", "", 0);
//If database opened successfully then set IsConnectionOpen to TRUE
if (SUCCEEDED(hr))
{
m_bIsConnectionOpen = TRUE;
}
}
//_RecordsetPtr pRecordset;
// Here I take data from a table called KRUSE1 which has two fields a0, and a1 of TEXT type
_bstr_t bstrQuery("SELECT * FROM Emaildetails");
_variant_t vRecsAffected(0L);
try
{
ConStr[0] = '\0';
strcat(ConStr, "SELECT * FROM ");
strcat(ConStr,"Emaildetails");
pRecordset = m_pConnection->Execute(ConStr, vRecordsAffected, 1);
//pRecordset = m_pConnection->Execute(bstrQuery, &vRecsAffected,adOptionUnspecified);
if (!pRecordset->GetEOFile())
{
cout <<"maari" ;
int i = 0;
_variant_t vFirstName;
_variant_t vLastName;
while (!pRecordset->GetEOFile())
{
vFirstName = pRecordset->GetCollect(L"email_address") ;
cout << "success" << endl;
vLastName = pRecordset->GetCollect(L"type") ;
// now you got vFirstName and vLastName values and do whatever u want.
i++;
pRecordset->MoveNext();
}
}
pRecordset->Close();
}
catch(...)
{
}
}
the connection is been made..and i think this program is able to access the mdb file also..but how to display the data ..
what is the variable to be used to get the data and display it in the output exe file??
ranjani
|
|
|
|
|
Been trying to write a statment here but not getting it to work I'm wondering if even the concept is valid for instace I want to do:
SELECT * FROM tasks WHERE Status LIKE 'Com%' AND WHERE Status NOT LIKE 'Complete%'
MySQL doesn't accept this as a valid statement, All I want it to do is select everything that starts with "com" but doesn't select anything that contains "Complete". Any ideas?
Thanks!
|
|
|
|
|
|
Doh! What was I thinking. Thanks for pointing it out.
|
|
|
|
|
Hi. I'm using msde 2000 sp3a for my database. Everytime I connect, I got this exception:
"Project SampleDB.exe encountered unhandled exception class System.Security.SecurityException."
I am using the free IDE from Borland, C#Builder Personal and my connection string looks like this:
"Initial Catalog=SampleDB;Data source=urstoff\\msde;Integrated security=SSPI";
This application runs on my other pc where I started it.
What's wrong?
|
|
|
|
|
This is more of a .NET Framework question.
IIRC, the ADO.NET classes (I assume you're using SqlConnection ) only allow access - using the CLR's code access security model - if the executable was loaded from the local hard disk.
It sounds like you're actually loading the executable across the network. This places the code in the Local Intranet rather than the My Computer security zone, and hence you don't have permission to use SqlConnection .
Copy the executable to the computer's hard disk, and it ought to work.
|
|
|
|
|
Thanks very much Mike. It compiled when I transfer the files from the network shared folders to the local drive. My source files are in My Documents that is redirected to a file server. Basically, the files run from the server.
|
|
|
|
|
Hi,
I'm a .net newbie & before this i have only worked with asp.
I'm trying to make a sample winforms intranet application using VS.net - c# and sql 2000 database.
The application works if executed on PC on which the sql-server is installed but does not seem to connect to the database when run on any other PC in the intranet.
Connection string used:
"data source=SUNNY;initial catalog=PROJ;password=sunny;persist security info=True;user id=softadmin;workstation id=192.168.1.2;packet size=4096";
Making the necessary changes in the connection string will do the trick OR does it required network socket programming...
Please provide guidance. Any url links to related articles will be of great help. Thanx in advance.
Sunny
|
|
|
|
|
Changing the connectionstring should suffice. The network plumbing has been done for you in the SQL Server OLEDB/ODBC drivers.
A quick checklist:
1. Check that the SQL Server is set up to use mixed mode authentication. (Both NT and SQL logins, NOT NT ONLY...)
2. Check all params in the connectionstring
3. Check you network infrastucture.
|
|
|
|
|
Hi Arjan, Thanx 4 clarifying the point - i've gone thru 2 books and done lots of browsing but could not get the answer whether i needed to do network programming in this scenario. I should have posted my problem on this forum - would have saved me lots of time.
AS PER YOUR CHECKLIST:
1) I checked and found that the authentication is mixed mode.
2) The params all seem to be correct, the code was generated by VS.Net IDE.
The only point i'm not clear about is whether "workstation id=192.168.1.2" is what is required to tell the program the location of the database. The database is on PC with ip address 192.168.1.2
The programs functions satisfactorily on the PC on which the database is located but returns an Alert message "Invalid User" to be displayed after validation if username & password is incorrect.
THE CONNECTION STRING USED:
"data source=SUNNY;initial catalog=PROJ;password=sunny;persist security info=True;user id=softadmin;workstation id=192.168.1.2;packet size=4096";
3) Network Infrastructure seems all ok - I'm able to access each one of the comps from the other.
Sunny.
|
|
|
|
|
Try changing the connection string to
"Data source=SUNNY;initial catalog=PROJ;user id=softadmin;password=sunny;"
accept the defaults for persisting security info (FALSE), packet size. I am not familiar with using 'workstation id' in a connection string. The data source should be the NODE Name where the server is located (or the SQL server instance name in the event you have multiple instances on the same box ( not likely with MSDE, but allowed with full SQL version). In any event, SQL server network library should resolve the targe host. You can also use the IP as the value for data source. Make sure you can ping the server node from the client. Try adding "Network library=Dbmssocn;" to the connection string to force the use of the TCPIP network library
also make sure you have added that user and login to the SQL database (sp_adduser, sp_grantdbaccess - the latter to the specific database, the former to the server in general, not all users get automatic access to all databases).
Make sure the user has access to the tables,etc in the data base (grant Select,insert,update,delete to 'user' on 'table')
you might want to download the SQl Server Books Online[^] for a complete reference to SQL 2000...(I don't think this comes with MSDE, but it is free, and indespensable if you are going to work with SQL 2000).
Another good reference for connection strings is here[^]
This is gor ADO,OLEDB,and ODBC connections, but the ADO/OLEDB strings for SQL server work just fine (just leave out the "Provider=sqloledb" part).
Genius may have its limitations, but stupidity is not thus handicapped. - Elbert Hubbard
|
|
|
|
|
Thank u Rob. Thanx Arjan. You guys were a great help. Finally i was able to solve the problem.
I used Try-Catch while connecting to the database & it returned the following error:
"The .net data sql provider (system.data.sqlclinet) requires microsoft data access components (mdac) version 2.6 or later"
So I downloaded MDAC 2.8 from the microsoft website and the problem was solved.
Expect to see a lot of posts from me on this forum. I'll be needing ur expert advise from time to time. Couldn't have solved this problem without your guidance. Thanx again.
Sunny.
|
|
|
|
|
|
Does any1 know how can I convert a database from SQL Server 2000 to SQ Server 7.0
Database is very simple and this shouldn't be very difficult I imagine.
Or am I wrong?...
Love is the law, love under will.
|
|
|
|
|
Easiest way is to use DTS.
Select the 2K database, and transfer all the objects. You might need to set the checkbox that suppresses non-2K specific features.
Steve S
|
|
|
|