still can't use SQL database
-
Here's what I've got: CDatabase DataBase; TRY { DataBase.OpenEx(_T("DSN=test;UID=;PWD="),CDatabase::noOdbcDialog); } CATCH(CDBException,e) { #ifdef _DEBUG MessageBox("ERROR Connecting"); #endif } END_CATCH TRY { DataBase.ExecuteSQL("INSERT INTO Annotation (AnnotationID,ImageID,Text) VALUES ('1','2','Capsule')"); } CATCH(CDBException,e) { #ifdef _DEBUG MessageBox("ERROR Inserting"); #endif } END_CATCH It appears to be connecting fine, but I always get "ERROR Inserting". 'Annotation' is the table I'm trying modify fields in. When I set up my DSN, I put the default database to the one that the table 'Annotation' is in (instead of master or model, etc). What am I doing wrong or failing to do? halblonious
-
Here's what I've got: CDatabase DataBase; TRY { DataBase.OpenEx(_T("DSN=test;UID=;PWD="),CDatabase::noOdbcDialog); } CATCH(CDBException,e) { #ifdef _DEBUG MessageBox("ERROR Connecting"); #endif } END_CATCH TRY { DataBase.ExecuteSQL("INSERT INTO Annotation (AnnotationID,ImageID,Text) VALUES ('1','2','Capsule')"); } CATCH(CDBException,e) { #ifdef _DEBUG MessageBox("ERROR Inserting"); #endif } END_CATCH It appears to be connecting fine, but I always get "ERROR Inserting". 'Annotation' is the table I'm trying modify fields in. When I set up my DSN, I put the default database to the one that the table 'Annotation' is in (instead of master or model, etc). What am I doing wrong or failing to do? halblonious
Taking a look at e->m_strError to see what the error is seems like a logical first step ;)
-
Taking a look at e->m_strError to see what the error is seems like a logical first step ;)
I never even knew to check that. Sadly, though, it doesn't really tell me much. Do you know of a good place to find prototype syntax for this stuff? What I had works for modifying an Access database, but doesn't seem to work on SQL. halblonious
-
I never even knew to check that. Sadly, though, it doesn't really tell me much. Do you know of a good place to find prototype syntax for this stuff? What I had works for modifying an Access database, but doesn't seem to work on SQL. halblonious
could you post the error message?
-
Here's what I've got: CDatabase DataBase; TRY { DataBase.OpenEx(_T("DSN=test;UID=;PWD="),CDatabase::noOdbcDialog); } CATCH(CDBException,e) { #ifdef _DEBUG MessageBox("ERROR Connecting"); #endif } END_CATCH TRY { DataBase.ExecuteSQL("INSERT INTO Annotation (AnnotationID,ImageID,Text) VALUES ('1','2','Capsule')"); } CATCH(CDBException,e) { #ifdef _DEBUG MessageBox("ERROR Inserting"); #endif } END_CATCH It appears to be connecting fine, but I always get "ERROR Inserting". 'Annotation' is the table I'm trying modify fields in. When I set up my DSN, I put the default database to the one that the table 'Annotation' is in (instead of master or model, etc). What am I doing wrong or failing to do? halblonious
At a guess, AnnotationID and ImageID are numeric (integer?) types. Try removing the quoting around them so it's just VALUES(1,2,'Capsule') Of course, there may also be uniqueness constraints which stop you inserting the same values more than once... Steve S