Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have the following code connect and fetch data from database. I need to import a dll (System.dll) but it returns an error while importing. What is the reason, i have the dll in the specified path. I have given the path in Project Properties.

I got error like this:
VB
Error   1   fatal error C1083: Cannot open type library file: 'c:\windows\microsoft.net\framework\v2.0.50727\system.dll': Error loading type library/DLL.   c:\users\test444\documents\visual studio 2008\projects\sampleado\sampleado\sampleado.cpp    3   SampleADO


please help..

XML
#include "stdafx.h"
#import "C:\Program Files (x86)\Common Files\System\ado\msado15.dll" rename_namespace("MSXML")  rename("EOF", "ADOEOF")
#import "System.dll" 
#include <windows.h>

#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
#include <sqlncli.h>
#include <stdio.h>
#include <cstdio>
#include <string>
#include <conio.h>
using namespace MSXML;
using namespace System;
void GetConnected(unsigned char *conn)
{
   

	HRESULT hr = S_OK;
	_RecordsetPtr pRstAuthors = NULL;
	hr = pRstAuthors.CreateInstance(__uuidof(Recordset));
	if(FAILED(hr))
	{
		printf("Failed creating record set instance");
		return;
	}
	pRstAuthors.Open("SELECT * FROM LabOpsStatus",conn, adOpenStatic, adLockReadOnly,adCmdText);
	pRstAuthors.MoveFirst();
	//Loop through the Record set
	if (!pRstAuthors.ADOEOF)
	{
		while(!pRstAuthors.ADOEOF)
		{
			printf("%s",pRstAuthors.Fields.GetItem("OBRESessionID").Value);
			printf("%s",pRstAuthors.Fields.GetItem("CurrentStep").Value);
			printf("%s",pRstAuthors.Fields.GetItem("Status").Value);
			//printf("%d - %sn",valField2,(LPCSTR)valField1);
			pRstAuthors.MoveNext();
		}
	}
	CoUninitialize();
	return;

   
}
 
void _tmain()
{
	GetConnected((unsigned char *)"DRIVER={SQL Server};SERVER=(local);Database=labops;UID=sa;PWD=99ARCF1RE;Trusted_Connection=yes");
    getch();
}
Posted
Comments
Orjan Westin 12-Dec-14 4:43am    
Looks like you are trying to import a .NET DLL into an unmanaged C++ project. That won't work. Why do you need System.dll?
Member 11168418 12-Dec-14 5:07am    
i was trying to use SqlDataAdapter(), DataSet(); and some other managed functions in unmanaged code, seems like a blunder. Is there any replacement for this kind of apis in unmanaged code. like myDataSet->WriteXml("G:/data7.xml"); to write as an xml. is ther any direct way to do this.
[no name] 22-Dec-14 14:19pm    
Compile your program as C++/CLI. System.dll is included by default. If you have .NET, you don't need COM or ADO. In fact, you should probably use C#.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900