-
April 4th, 2013, 10:34 PM
#1
[Microsoft][SQL Server Native Client 10.0]String data, right truncation
Hi all,
I wrote my own SQLDatabase class base on TinyODBC class, and i have problem with my SQLPreparedStatement::SetString method.
In my app, i construct new instance of SQLPreparedStatement class and call SetString method to bind a string to statement. When i execute that statement i got an error, it says "[Microsoft][SQL Server Native Client 10.0]String data, right truncation".
Code:
ODBC::SQLConnection conn(Configuration::Database->ConnectionString());
conn.OpenEx();
ODBC::SQLResult* pResult = conn.Query(_T("SELECT ISNULL(MAX(ProductCategoryID), 0) + 1 FROM Production.ProductCategory"));
if (pResult != NULL)
{
int nNewProductCategoryID = pResult->Field(1).AsInt32();
ODBC::SQLFreeResult(&pResult);
ODBC::SQLPreparedStatement stmt(conn, _T("INSERT INTO Production.ProductCategory(ProductCategoryID, Name) VALUES (?, ?)"));
stmt.SetInt32(0, nNewProductCategoryID);
stmt.SetString(1, (LPCTSTR)sProductCategoryName);
if(stmt.Execute())
{
nProductCategoryID = nNewProductCategoryID;
return true;
}
}
I dont know why i get that error because in other same statement (that use from TinyODBC class), statement execute success with no error.
SQLDatabase classODBCDatabase.rar
TinyODBC classTinyODBC.rar
Thank in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|