Showing posts with label based. Show all posts
Showing posts with label based. Show all posts

Thursday, March 29, 2012

Error when updating bigint columns using ADO

I am attempting to write a conversion of our product for Compact Edition; we already provide it based on SQL Server. The database interface uses ADO through a Python-win32com adaptor, and has worked fine so far. (Note: *not* ADO.net, just plain old COM)

Now, a curious thing happens. When inserting new data through a Recordset, everything works fine - except for columns defined as bigint. There are no exceptions thrown, but when you read the columns back they contain nothing but zeroes. Do the same to any other column type - I've tried integer, numeric, float, nvarchar and ntext so far, and they all seem to work just fine. It does not seem to be conversion-related either, since I've tested the exact same data to various column types. And using bigint on regular SQL Server works just fine.

The code involved is quite unspectacular, and simply switching the column types to integer would solve the immediate problem, but causes potential future issues since we normally store internal IDs in bigint columns, and the values may grow quite large.
This may indicate a problem with compatibility betweeen the 3rd party python ADO adaptor and the SQL CE OLEDB provider.

Monday, March 19, 2012

Error when creating a table based function

I'm trying to create a table based function using SMO. The problem is that I get an error saying that I need to set the DataType property on the function before it can be created. However, the documentation clearly says that the DataType property is null for Table based functions. I can't even set this value to null either!

Here's a code snippet that shows what I'm trying to do.

if (returnType.ToLower() != "table")

{

Type clrDataType = Type.GetType(returnType);

returnSqlDataType = GetSqlDataType(clrDataType);

function.FunctionType = Smo.UserDefinedFunctionType.Scalar;

function.DataType = returnSqlDataType;

}

else

{

function.FunctionType = Smo.UserDefinedFunctionType.Table;

function.TableVariableName = xmlNode.Attributes["tableVariableName"].Value;

XmlNode returnTableDescription = GetChildOfParent(xmlNode, "ReturnTableDescription");

XmlNode columnsNode = GetChildOfParent(returnTableDescription, "Columns");

foreach (XmlNode columnNode in columnsNode.ChildNodes)

{

function.Columns.Add(CreateUdfColumn(function, columnNode));

}

}

The xmlNode that is being referenced is an XmlNode that is describing how to create the table. returnType is a variable that is set from one of the xmlNode's attributes.

When I call on function.Create() then I get the error that I posted above. Any help anyone can give is appreciated. One thing I also tried doing was to connect to an already existing Table based function and look at its SMO properties. Sure enough, its DataType property was null.

MSFT: Is this a bug?

Never mind on this post.....it was my mistake. The DataType property not being set wasn't on the function itself, but rather on the columns collection.

Problem solved.

Friday, February 17, 2012

Error sorting subform

Has anyone ever gotten this error message when sorting an Access Project subform based on an SQL table?

"column prefix [name of subform] does not match with the table name or alias used in the query".

I built a main parts form from a SQL table [Parts] using Access Project. I then added a subform [FSinvPARThistory] based on another SQL table [PartHistory] to record history for the part. The two are linked together using primary key 'ID'. I can sort the subform but then when I go to select another record on the main form I get the above error message.

Can you not sort a subform? If not, how can I prevent users from inadvertantly sorting a subform and getting the same message?

Thanks.

Open the subform and sort the resultset there.

Error sorting subform

Has anyone ever gotten this error message when sorting an Access Project subform based on an SQL table?

"column prefix [name of subform] does not match with the table name or alias used in the query".

I built a main parts form from a SQL table [Parts] using Access Project. I then added a subform [FSinvPARThistory] based on another SQL table [PartHistory] to record history for the part. The two are linked together using primary key 'ID'. I can sort the subform but then when I go to select another record on the main form I get the above error message.

Can you not sort a subform? If not, how can I prevent users from inadvertantly sorting a subform and getting the same message?

Thanks.

Open the subform and sort the resultset there.