|
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 it )
|
|
|
|
|
HI all
Pleasetell me the steps of Former US National Security Agency (NSA) standard algorithm.
I googled about this wiping algirithm but didnt get any success.
so please help me.
Thanks
|
|
|
|
|
I'm certain the NSA has 1000s of algorithms and that they are quite secured in the USA.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I need to save url's contents(gif,jpeg) to file using visual c++, like function urlwrite with matlab; my email: rfano@walla.com
|
|
|
|
|
|
thank you for the answer, but i have one question: how can i use the planified task (windows) with this program
|
|
|
|
|
|
I'm implementing a OO framework for the Win32 User Interface. The normal stuff like creating windows and so forth doesn't seem to be a problem, but hanling the messaging is.
I have a base Control class that does all the CreateWindow, font settings and other general stuff. Then I derive other controls from it, just setting the classname for the class to a something else to create a specific kind of control, like setting the classname to BUTTON, creates a button control. This works fine, but I still have to do the WM_COMMAND processing in the Window/Frame Control. I'd like to do this in the derived control class. I've tried chaining that derived control's WNDPROC's, but when trying to retrieve that specific object through a GetWindowLong ( GWL_USERDATA ) doesn't work, as the control that has the original WNDPROC is set in the USERDATA variable..
I'm pretty stuck ... hope you understand what I mean. I'll post some code if you don't understand.
Thanx
|
|
|
|
|
tiaanl wrote: I'll post some code if you don't understand.
Quite interesting. Go ahead.
Nibu thomas
Software Developer
|
|
|
|
|
Only have code on home machine , but it looks something like this:
class Control {
public:
virtual bool Create ( Control *parent );
protected:
virtual bool CreateHandle ( void );
virtual bool SetParams ( void );
}
bool Control::Create ( Control *parent )
{
SetParams ();
CreateHandle ();
}
bool Control::CreateHandle ( void )
{
handle = CreateWindowEx ( ... )
SetWindowLong ( handle, GWL_USERDATA, this );
}
bool SetParams ( void )
{
style = WS_CHILD | WS_VISIBLE;
classname = "STATIC";
}
This is a stripped down skeleton of it and when I want to create a derived control I do this:
class EditControl : public Control
{
virtual bool SetParams ( void );
}
bool CEditControl::SetParams ( void )
{
classname = "EDIT";
}
Boom! Edit control. Same with a buttons, list views, tree views, etc.....
For a actual window control, I derive a CustomControl class which adds some registration methods to register a new window class with WNDPROC etc....
Now here's the problem: I add eg. EditControl as a member in MainWndControl and run the create with MainWndProc as the parent. That window has it's own WNDPROC, and I do a GetWindowLong ( GWL_USERDATA ) inside the wndproc to get a pointer to the actual MainWndControl. Then I add some WM_COMMAND message handling in there to do what the buttons and edit controls is supposed to do. This is fine, but what I want to do is add message handling to specific Control classes to handle things like WM_PAINT, WM_LBUTTONUP, WM_FOCUS and that kind of generic messages.
This is where I tried chaining the WNDPROC's, but the Control receiving the message isn't the Control that has to get processed, because the GWL_USERDATA is set to something else.....
|
|
|
|
|
Are you looking for something like THIS[^]?
Maxwell Chen
|
|
|
|
|
Looks really promising - will have a go at it and give some feedback....
Thanx a million
|
|
|
|
|
what is the best way to learn COM ?
|
|
|
|
|
For beginners - Michael Dunn's articles on COM.
Start here[^]
Nibu thomas
Software Developer
|
|
|
|
|
Thank u Thomas That article is so nice.
|
|
|
|
|
Krishnatv wrote: Thank u Thomas That article is so nice.
You should read on. He has written these articles in a series. Like Part - 1, Part - 2.
Nibu thomas
Software Developer
|
|
|
|
|
I want to load bitmap on dialog box,using bitmap buffer and not willing to save it(bimap buffer) as file.Can any one please help!!!!!!!!
Thanks in advance
Rahul
|
|
|
|
|
For loading a bitmap from a resource use LoadBitmap and from a file use LoadImage .
Nibu thomas
Software Developer
|
|
|
|
|
(Nibu thomas :
For loading a bitmap from a resource use LoadBitmap and from a file use LoadImage.)
and CImage and OleLoadPicture for read graphic files
|
|
|
|
|
HI Guys,
I have created a dialog and placed two buttons on it with the owner draw property set to true to show the bitmap on it using LoadBitmaps.On the dialog I have placed a picture control with some image.
Now when I run the application the picture control is seen with the buttons behind it. When I take the mouse to the location of the buttons the buttons become visible.
I want the button to be shown as soon as the dialog is displayed.
What is the problem and how can it be resolved?
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
This is because the picture control is overlapping the buttons.
The last control that gets painted here is the picture control hence it paints over the buttons.
Nibu thomas
Software Developer
|
|
|
|
|
|
|
Are you making a splash screen?
If so why don't you simply BitBlt to the dialog.
If not bring the buttons up the Z-Order using SetWindowPos .
Nibu thomas
Software Developer
|
|
|
|
|
Thanks for your time guys.
But I got how to do this.
I would like to share the solution with all of you.
Set the Transparent property of the button to TRUE . That is all.
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|