Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone...
I have a problem creating a very simple database application using ODBC in visual studio 2008..
I started with dialog based application, and add manually a ODBC consumer wizard and i found problem when i checked the "Binding All Column" check box. after pressed OK, visual studio stucked..So restart again and unchecked it..Works

My application are inputting 2 edit controls with integer variables and store it in a database with 1 table 3 fields (ID, X, Y).

Now, ihave this code
C++
CTable1::CTable1(CDatabase* pdb)
    : CRecordset(pdb)
{
    m_var3 = 0;
    m_var4 = 0;
    m_nFields = 3;
    m_nDefaultType = dynaset;
}

and
C++
void CTable1::DoFieldExchange(CFieldExchange* pFX)
{
    pFX->SetFieldType(CFieldExchange::outputColumn);
    RFX_Int(pFX, _T("[X]"), m_var3);
    RFX_Int(pFX, _T("[Y]"), m_var4);

// Macros such as RFX_Text() and RFX_Int() are dependent on the
// type of the member variable, not the type of the field in the database.
// ODBC will try to automatically convert the column value to the requested type
}

and i build it,debug it, and press a DO button...
message box appears "Syntax Error in FROM cause"

How can i find the syntax?
OS Windows 7
Visual Studio 2008
Posted
Updated 6-Sep-11 19:46pm
v3

You need to check the query you are using.
Debug, get it in a string, and run it in the backend database editor (if possible) to see if it is working.
 
Share this answer
 
Comments
Kay Andrian Fikar 7-Sep-11 3:19am    
Yes..i forgot to add table name on the SQL
The 'FROM' clause might be missing the 'Table Name'. Check for it. Try to print the query in output window using OutputDebugString() function. Copy that query and try to run in the database editor.
 
Share this answer
 
Comments
Kay Andrian Fikar 7-Sep-11 3:16am    
Well, after i review again, the GetDefaultSQL doesnt have any table name...and i added and simply work out.
OleDbConnection con3 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Hp Laptop\\Documents\\Hospital Info.accdb");
string path = "select Imagepath from Image where Hospitalcode='" + hoscodetemp +"'";
OleDbCommand cmd3 = new OleDbCommand(path);
OleDbDataAdapter ad3 = new OleDbDataAdapter(path, con3);
DataSet ds3 = new DataSet();
DataTable dt3 = new DataTable();
ad3.Fill(ds3);
if(ds3!=null && ds3.Tables[0].Rows.Count > 0)
{
dt3=ds3.Tables[0];
// pictureBox1.Image="";
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900