Click here to Skip to main content
15,918,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalbuilding a string from hexadecimal values Pin
Kuniva4-Sep-02 10:11
Kuniva4-Sep-02 10:11 
GeneralRe: building a string from hexadecimal values Pin
Andrew Peace4-Sep-02 10:50
Andrew Peace4-Sep-02 10:50 
GeneralRe: building a string from hexadecimal values Pin
Kuniva4-Sep-02 11:11
Kuniva4-Sep-02 11:11 
GeneralRe: building a string from hexadecimal values Pin
Christian Graus4-Sep-02 11:54
protectorChristian Graus4-Sep-02 11:54 
GeneralAdding a data source question Pin
hiseldl4-Sep-02 10:00
hiseldl4-Sep-02 10:00 
GeneralRe: Adding a data source question Pin
Bill Wilson4-Sep-02 11:03
Bill Wilson4-Sep-02 11:03 
GeneralRe: Adding a data source question Pin
hiseldl4-Sep-02 11:18
hiseldl4-Sep-02 11:18 
GeneralRe: Adding a data source question Pin
Pavel Klocek4-Sep-02 12:05
Pavel Klocek4-Sep-02 12:05 
Here is some code to do this:

BOOL CreateSource(LPCSTR lpszDriver, LPCSTR lpszAttributes, BOOL bSystem /*= TRUE*/)
{
	//nahradit '$' nulou ('\0') v lpszAttributes 
	char attr[500];
	char driver[250];

	if(lpszAttributes)
	{
		int mlen = strlen(lpszAttributes);
		strcpy(attr,lpszAttributes);
		char* ch = attr;
		for (int i=0; i<mlen; i++,ch++) {if (*ch == '$') *ch = '\0';}
	}
	else
	{
		attr[0] = 0;
	}

	//Pridani druhe nuly za retezec s driverem
	if(lpszDriver)
	{
		int mlen = strlen(lpszDriver);
		strcpy(driver,lpszDriver);
		strcat(driver,"\0");
	}
	else
	{
		driver[0] = 0;
	}

	WORD request;
	if(bSystem) request = ODBC_ADD_SYS_DSN;
	else request = ODBC_ADD_DSN;

	//zavolani ODBC API
	return SQLConfigDataSource(NULL,request,driver,attr);
}

BOOL CreateAccessSource(LPCSTR lpszName, LPCSTR lpszPath, LPCSTR lpszDescription /*= NULL*/, BOOL bSystem /*= TRUE*/)
{
	char* szDesc;
	szDesc=new char[500];

	if(lpszDescription)
		sprintf(szDesc,"DSN=%s$ DESCRIPTION=%s$ DBQ=%s$ FIL=MicrosoftAccess$ DEFAULTDIR=C:\\$$",lpszName,lpszDescription,lpszPath);
	else
		sprintf(szDesc,"DSN=%s$ DBQ=%s$ FIL=MicrosoftAccess$ DEFAULTDIR=C:\\$$",lpszName,lpszPath);
	
	return CreateSource("Microsoft Access Driver (*.mdb)",(LPCSTR)szDesc,bSystem);
}


Pavel
Sonork 100.15206
GeneralRe: Adding a data source question Pin
hiseldl5-Sep-02 5:38
hiseldl5-Sep-02 5:38 
GeneralRe: Adding a data source question Pin
Pavel Klocek5-Sep-02 5:43
Pavel Klocek5-Sep-02 5:43 
Generalgraceful exit, and safeguards - help! Pin
ns4-Sep-02 9:45
ns4-Sep-02 9:45 
GeneralRe: graceful exit, and safeguards - help! Pin
Chris Losinger4-Sep-02 10:00
professionalChris Losinger4-Sep-02 10:00 
GeneralRe: graceful exit, and safeguards - help! Pin
Stephane Rodriguez.4-Sep-02 10:44
Stephane Rodriguez.4-Sep-02 10:44 
GeneralRe: graceful exit, and safeguards - help! Pin
Tomasz Sowinski4-Sep-02 23:01
Tomasz Sowinski4-Sep-02 23:01 
GeneralCRichEditCtrl and URL link … Pin
Hadi Rezaee4-Sep-02 9:06
Hadi Rezaee4-Sep-02 9:06 
GeneralRe: CRichEditCtrl and URL link … Pin
Matthew R. Miller4-Sep-02 10:22
Matthew R. Miller4-Sep-02 10:22 
GeneralRe: CRichEditCtrl and URL link … Pin
Hadi Rezaee4-Sep-02 10:34
Hadi Rezaee4-Sep-02 10:34 
GeneralRe: CRichEditCtrl and URL link … Pin
Matthew R. Miller4-Sep-02 10:45
Matthew R. Miller4-Sep-02 10:45 
GeneralRe: CRichEditCtrl and URL link … Pin
Hadi Rezaee4-Sep-02 10:51
Hadi Rezaee4-Sep-02 10:51 
GeneralRe: CRichEditCtrl and URL link … Pin
Matthew R. Miller4-Sep-02 15:50
Matthew R. Miller4-Sep-02 15:50 
GeneralRe: CRichEditCtrl and URL link … Pin
Hadi Rezaee4-Sep-02 12:33
Hadi Rezaee4-Sep-02 12:33 
GeneralRe: CRichEditCtrl and URL link … Pin
Matthew R. Miller4-Sep-02 15:53
Matthew R. Miller4-Sep-02 15:53 
GeneralRe: CRichEditCtrl and URL link … Pin
Matthew R. Miller4-Sep-02 15:57
Matthew R. Miller4-Sep-02 15:57 
GeneralRe: CRichEditCtrl and URL link … Pin
Matthew R. Miller4-Sep-02 16:00
Matthew R. Miller4-Sep-02 16:00 
GeneralRe: CRichEditCtrl and URL link … Pin
Hadi Rezaee4-Sep-02 22:43
Hadi Rezaee4-Sep-02 22:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.