WebDAV search on Integer data type - webdav

I have a WebDAV query which search for e-mails on an Exchange 2003 server on field 'TestField' with the value '3'. This field contains data of the type Integer (an another application set this field with data type OlUserPropertyType.olInteger).
SELECT "TestField" FROM "http://server/exchange/mailbox/mialbox" WHERE "TestField" = 3
I received always a "Bad Request (400)". On another fields with another data types (string) is works.
What is wrong in these? Must I cast the value but how can I do that?

Problem solved. Casting is the solution.
WHERE CAST("TestField" AS "int") = 3

Related

DataType Conversion from string to date & from string to ip in convert processor

I want to convert one of the field from string to date format.
and secondly from string to ip datatype using pipeline file created.
I am trying the same with the convert processor available but it will throw error as
"ip is not supported" and date format is not supported I checked the same from the document.
Can someone suggest how to perform this task.
I want my date & IP field convertible to their respective datatype and the mappings should be visible
I have tried with
convert:{ field:response_date
type: auto
}
Tried with auto as from the document it was mentioned that it will convert the field nearly to a matching datatype.
This also didn't worked.
Can anyone suggest what do to in this case.

BizTalk 2013 WCF-SQL adapter to insert into decimal(38,20)

I am having problems inserting values into SQL Server columns of type decimal(38, 20) from BizTalk 2013 using WCF-SQL adapter. I get InvalidCastException with message: "System.InvalidCastException: Specified cast is not valid"
If I test column type decimal(18,18) it works.
Seems like the WCF-SQL adapter does not handle decimal with very high precision. Question is what is the limitation? And, if there is a workaround?
When I generate XSD from database table information, decimal(38,20) turns into xs:string with length restriction of 40. Maybe this is a sign of that WCF-SQL adapter cannot handle such precision...? I have also tested to alter the XSD to be xs:decimal, but no difference.
Anyone?
ADDITION:
Did not find any "good" way to handle this limitation.
Final setup is: XML => WCF-SQL adapter => Stored Procedure with table type parameter containing varchar(40) columns => CAST table variable columns to decimal(38,20) one-by-one => INSERT into destination table.
So, solution was to modify table type to accept varchar, and manually convert in stored procedure.
Would be happy if someone could explain the better solution!
Decimal precision is limited to the .NET framework type. See here.
Also described in the BizTalk documentation here. "Decimal if precision <= 28. String if precision > 28".
So your way of handling with strings is an option. Use the Round functoid in your map to the SQL schema if you don't really need more than 29 positions.
Another option you could consider is changing the regional settings for the BizTalk host user running the send port. The current setting/language of your decimal separator is a comma instead of a dot (or the other way around) and not matching the data type for SQL Server. For this option you have to keep the type as string in your schema and keep it decimal in your SQL Server table.

How to store Multiple radio button and check box values in sqlserver database using Asp.net?

I am making database using sqlserver2008. Which data type I should choose? In php I use ENUM and in value field I put like that 'Male','Female'. what is the way in sqlserver to create radio button and check box field? And how to insert these in sqldatabase?
I have two gender radio button with different ids so I apply check before insertion i.e.
connection.open();
string gen = "";
if(rdm.Checked == true)
{
string gen ="Male";
}
else if (rdf.Checked == true)
{
string gen = "Female";
}
and in insert value field I just put +gen+ but I receive error: Error 1 A local variable named 'gen' cannot be declared in this scope because it would give a different meaning to 'gen', which is already used in a 'parent or current' scope to denote something else
I usually store dotnet Enums as integers (smallint) in SQL server, sometimes when the database is queried directly by users I use varchar values for readability. Both can easily be converted back to Enums.
I will commonly create a code table in the database to represent my .net enums. Then the associated field in the main data table is just an int with a FK constraint to the code table.
This allows for compact storage and transmission of the data, ensures that no out of range values are entered into the database, and if anyone needs to query the db directly they can join to the code tables to find out what the integers mean.

Cannot insert null where field is Guid (object in SqlDataSource)

I have a table which links to another table in the ASP.NET membership schema.
Problem is, all the PKs for the ASP.NET tables are uniqueidentifier so mine has to be too. When I add a SqlDatasource and call its Insert() method, I get the following error:
Cannot insert the value NULL into column 'DiscountCode', table 'CreamDb.dbo.CustomInfo1'; column does not allow nulls. INSERT fails.
The statement has been terminated.
The uniqueidentifier is also treated as an object (its data type), but there is no Guid data type. I had this problem before, but the schema was much simpler so I could fix it.
How can I go about fixing this? If I get rid of the data type part in the markup (so just leave the field/parameter name but not the data type stuff), I get another error so that is not possible.
Thanks
What do you mean by "there is no Guid data type"? What's wrong with System.Guid? Can't you just use Guid.NewGuid(), set the field appropriately, and do the insert?
EDIT: Just to give a bit more meat: attach an event handler to the Inserting event, and populate the field then, via the DbCommand returned by SqlDataSourceCommandEventArgs.Command. Or change the SQL used by the INSERT command to ask the database to populate the GUID field for you.
A popullar approach when dealing with references to the ASP.NET Membership Provider's data is, instead of keeping a proper foreign key to the GUIDs, instead store something like the LoweredUserName in your table. Then, use the Membership Provider's API to interact with the object you need. In some cases, you need an ObjectDataSource abstraction layer to accomplish CRUD scenarios.
Set the default value of the column in SQL Sever to "newid()".
Asp.net won't send the value, and the field will get a new guid.

L2Entities, stored procedure and mapping

Finally checked out L2E framework and ran into problems almost instantly.
Yeah, i know... i should read some books before.
Situation:
entity with props -> id and name.
entity is mapped to table, which has id and name columns.
sproc, which returns ONLY id column.
Problem:
ObjectResult<MyProp> result = _container.MyStoredProcedure(uberParameter);
Calling this will cause an error
[guilty method goes here] threw exception:
System.Data.EntityCommandExecutionException: The data reader is incompatible with the specified 'DataBase.MyPropTableObject'. A member of the type, 'name', does not have a corresponding column in the data reader with the same name..
Problem #2:
Can`t "just return" that field, cause that column has XML data type, but sproc uses fancy select statements, which causes:
Msg 421, Level 16, State 1, Line 1
The xml data type cannot be selected as DISTINCT because it is not comparable.
Question:
Is it possible to exclusively turn off mapping for this entity prop only for this one sproc?
Problem 1 is due to the proc not having the columns to populate the entity. You don't really need the proc if you have mapped the table, just select the field you want from it using linq
var result = MyEntities.EntityIMapped.First(r => r.id = uberParameter).Name;
Would give you the value from the Name column of the table for the given id. You don't need to use a stored proc for this.
Problem 2 sounds like it is in the proc, I would think that distinct on an xml data column would give a lot of results, but I'm only guessing as I don't know your solution.
This is not a direct answer for your question but, hopefully it will point you in the right direction.

Resources