Click here to Skip to main content
15,921,295 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: RAND_MAX constant Pin
9ine3-May-06 3:00
9ine3-May-06 3:00 
GeneralRe: RAND_MAX constant Pin
David Crow3-May-06 2:26
David Crow3-May-06 2:26 
Questionimplementing audio tuner UI Pin
atimpoo2-May-06 23:39
atimpoo2-May-06 23:39 
AnswerRe: implementing audio tuner UI Pin
Cedric Moonen2-May-06 23:48
Cedric Moonen2-May-06 23:48 
GeneralRe: implementing audio tuner UI Pin
atimpoo3-May-06 0:26
atimpoo3-May-06 0:26 
GeneralRe: implementing audio tuner UI Pin
Cedric Moonen3-May-06 1:30
Cedric Moonen3-May-06 1:30 
GeneralRe: implementing audio tuner UI Pin
atimpoo3-May-06 1:33
atimpoo3-May-06 1:33 
QuestionConnecting to access db- newbie Pin
antonaras_marcou2-May-06 23:38
antonaras_marcou2-May-06 23:38 
Hi again.
This time i have tons of problems. I'm trying to learn how to connect to a db using ODBC. unfortunatly i can't find any good reference to show me how to do this (or maybe i'm stubit). Anyway I know is not right to ask from u to teach me how but u r me last chance so thanks for any help.

i wan't to built a spam filter that uses statistics to classify an email.
This is done using a db to store all words previously evaluated.

The db has only one table with the following rows:string word,int spam, int legitimate

i want to connect to the db and check one by one all the words(tokens) of the email if exists in the db and what value they have

i know i'm not very clear and i'm sorry. So far i manage to connect using some codei found on the web.

#include windows.h
#include sqlext.h
#include stdio.h
#include string.h

int main(void)
{
std::string token="viagra"
HENV hEnv = NULL;// Env Handle from SQLAllocEnv()
HDBC hDBC = NULL;// Connection handle
HSTMT hStmt = NULL;// Statement handle
UCHAR szDSN[SQL_MAX_DSN_LENGTH] = "project";// Data SourceNamebuffer
UCHAR* szUID = NULL;// User ID buffer
UCHAR* szPasswd = NULL;// Password buffer
UCHAR szWord[128];// word buffer
SDWORD cbWord;// word buffer bytes recieved
UCHAR szSqlStr[] = "Select * From tblDictionary Where Feature='token'";// SQL string

RETCODE retcode;// Return code

// Allocate memory for ODBC Environment handle
SQLAllocEnv (&hEnv);
// Allocate memory for the connection handle
SQLAllocConnect (hEnv, &hDBC);
// Connect to the data source "dictio" using userid and password.
retcode = SQLConnect (hDBC, szDSN, SQL_NTS, szUID, SQL_NTS, szPasswd, SQL_NTS);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
// Allocate memory for the statement handle
retcode = SQLAllocStmt (hDBC, &hStmt);
// Prepare the SQL statement by assigning it to the statement handle
retcode = SQLPrepare (hStmt, szSqlStr, sizeof (szSqlStr));
// Execute the SQL statement handle
retcode = SQLExecute (hStmt);
// Project only column 1 which is the word
SQLBindCol (hStmt, 1, SQL_C_CHAR, szWord, sizeof(szWord), &cbWord);
// Get row of data from the result set defined above in the statement
retcode = SQLFetch (hStmt);
while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
printf ("\t%s\n", szWord);
retcode = SQLFetch (hStmt);// Fetch next row from result set
}
// Free the allocated statement handle
SQLFreeStmt (hStmt, SQL_DROP);
// Disconnect from datasource
SQLDisconnect (hDBC);
}

// Free the allocated connection handle
SQLFreeConnect (hDBC);
// Free the allocated ODBC environment handle
SQLFreeEnv (hEnv);
return 0;

}

This code only gets the first colum i want to get all 3 colums and i want to check if the word does not exists i want to INSERT
i know is a lot of work to ask from u but believe me i tried and i can't find what i'm looking for.

Thanks again appriciate the help.

p.s if i ever make this spam filter to work i'll give it as a gift to all of u(though i doubt itBig Grin | :-D )
QuestionNSA standard Pin
rajeevktripathi2-May-06 23:09
rajeevktripathi2-May-06 23:09 
AnswerRe: NSA standard Pin
Maximilien3-May-06 2:56
Maximilien3-May-06 2:56 
Questionsaving contents of url to file Pin
fanomezana2-May-06 22:31
fanomezana2-May-06 22:31 
AnswerRe: saving contents of url to file Pin
Michael Dunn2-May-06 22:50
sitebuilderMichael Dunn2-May-06 22:50 
GeneralRe: saving contents of url to file Pin
fanomezana4-May-06 0:45
fanomezana4-May-06 0:45 
AnswerRe: saving contents of url to file Pin
Hamid_RT3-May-06 0:24
Hamid_RT3-May-06 0:24 
QuestionWrapping the Win32 User Inteface in OO Pin
User 28107302-May-06 22:30
User 28107302-May-06 22:30 
AnswerRe: Wrapping the Win32 User Inteface in OO Pin
Nibu babu thomas2-May-06 23:05
Nibu babu thomas2-May-06 23:05 
GeneralRe: Wrapping the Win32 User Inteface in OO Pin
User 28107302-May-06 23:21
User 28107302-May-06 23:21 
QuestionRe: Wrapping the Win32 User Inteface in OO Pin
Maxwell Chen3-May-06 0:13
Maxwell Chen3-May-06 0:13 
AnswerRe: Wrapping the Win32 User Inteface in OO Pin
User 28107303-May-06 0:31
User 28107303-May-06 0:31 
QuestionCOM Pin
Krishnatv2-May-06 22:24
Krishnatv2-May-06 22:24 
AnswerRe: COM Pin
Nibu babu thomas2-May-06 22:27
Nibu babu thomas2-May-06 22:27 
GeneralRe: COM Pin
Krishnatv2-May-06 23:10
Krishnatv2-May-06 23:10 
GeneralRe: COM Pin
Nibu babu thomas2-May-06 23:14
Nibu babu thomas2-May-06 23:14 
QuestionNeed help on loading bitmaps using bitmap memory without saving it as a file on dialog box Pin
RahulOP2-May-06 22:12
RahulOP2-May-06 22:12 
AnswerRe: Need help on loading bitmaps using bitmap memory without saving it as a file on dialog box Pin
Nibu babu thomas2-May-06 22:14
Nibu babu thomas2-May-06 22:14 

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.