•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS Access and FileMaker Pro section within the Web Development category of DaniWeb, a massive community of 426,485 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,193 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS Access and FileMaker Pro advertiser: Programming Forums
Views: 4572 | Replies: 2
•
•
Join Date: Sep 2004
Posts: 11
Reputation:
Rep Power: 5
Solved Threads: 0
I am having problems making my code access the primary key, and to print information out to screen in a C++ program that I Am writing. Need some help PLEASE ! The Primary Key Name is ID1. HERE IS THE CODE
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <tchar.h>
#include "ODBCWrapper.cpp"
//make sure you include the namespace
using namespace std;
using namespace ODBC;
int main(void) {
MDBConnection link;
if(link.Connect("C:\\Documents and Settings\\Chester Mayle\\My Documents\\My Data Sources\\db1.mdb")) {
ODBCStmt Stmt(link);
SQLExecDirect(Stmt, (SQLTCHAR *) _T("USE Foo"), SQL_NTS);
int pos = 1;
TCHAR strQuery[256] = _T("SELECT car1 FROM \ID Data Base\where ID1='2%'");
//t
//tl
//TCHAR strQuery[256] = _T("SELECT * FROM \ID Data Base\"");
//int nRet =
cout<<Stmt.Query(strQuery);
printf("%5d:\tColumns\t%d\r\n\r\n", Stmt.GetColumnCount(), 0);
string cg;
//SELECT [ID1] FROM [ID Data Base] where ID1='2%'";
while(Stmt.Fetch()) {
ODBCRecord rec(Stmt);
//printf("Row %5d\r\n", pos);
INT i = 0;
while(i < Stmt.GetColumnCount()) {
TCHAR Desc[512] = _T("");
SQLINTEGER cbDesc = 0;
rec.GetData(i + 1, Desc, sizeof(Desc), & cbDesc);
//TCHAR Name[256] = _T("");
TCHAR Name[256] = _T( "WHERE ID1=2%");
rec.GetColumnName(i + 1, Name, sizeof(Name));
i++;
printf("\t%15s\t\\>\t%25s\r\n", Name, Desc);
}
pos++;
};
}
else {
printf("Connection failed.");
}
link.Disconnect();
//getch();
char asd;
cin>> asd;
return 0;
}
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <tchar.h>
#include "ODBCWrapper.cpp"
//make sure you include the namespace
using namespace std;
using namespace ODBC;
int main(void) {
MDBConnection link;
if(link.Connect("C:\\Documents and Settings\\Chester Mayle\\My Documents\\My Data Sources\\db1.mdb")) {
ODBCStmt Stmt(link);
SQLExecDirect(Stmt, (SQLTCHAR *) _T("USE Foo"), SQL_NTS);
int pos = 1;
TCHAR strQuery[256] = _T("SELECT car1 FROM \ID Data Base\where ID1='2%'");
//t
//tl
//TCHAR strQuery[256] = _T("SELECT * FROM \ID Data Base\"");
//int nRet =
cout<<Stmt.Query(strQuery);
printf("%5d:\tColumns\t%d\r\n\r\n", Stmt.GetColumnCount(), 0);
string cg;
//SELECT [ID1] FROM [ID Data Base] where ID1='2%'";
while(Stmt.Fetch()) {
ODBCRecord rec(Stmt);
//printf("Row %5d\r\n", pos);
INT i = 0;
while(i < Stmt.GetColumnCount()) {
TCHAR Desc[512] = _T("");
SQLINTEGER cbDesc = 0;
rec.GetData(i + 1, Desc, sizeof(Desc), & cbDesc);
//TCHAR Name[256] = _T("");
TCHAR Name[256] = _T( "WHERE ID1=2%");
rec.GetColumnName(i + 1, Name, sizeof(Name));
i++;
printf("\t%15s\t\\>\t%25s\r\n", Name, Desc);
}
pos++;
};
}
else {
printf("Connection failed.");
}
link.Disconnect();
//getch();
char asd;
cin>> asd;
return 0;
}
•
•
•
•
•
•
•
•
DaniWeb MS Access and FileMaker Pro Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation ajax apple asp code combo computing core cracked creative data database design developer development dropdownlist gates hack hacker howto illustrator ip key kms mac management melinda microsoft module net news office photoshop print pro processor product registration reuse security serial service software sql survey toread tutorials vista web
- Validation for the primary key in the database (JSP)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- HELP! Need someone that Knows SQL to tell Me How to Access a Primary Key (C)
- Need to make program access a data base primary key number entered by user (C)
- Primary Key Issue (Visual Basic 4 / 5 / 6)
Other Threads in the MS Access and FileMaker Pro Forum
- Previous Thread: how to create db of correspondence in access
- Next Thread: How to export excel data to a search engine?



Threaded Mode