Showing posts with label property. Show all posts
Showing posts with label property. Show all posts

Thursday, March 22, 2012

conversion error

Please help.

I have an aspx page with a drop down list(ddlCategories), and a datalist(dlLinks). The drop down lists data property is a uniqueidentifier from a table.

When an item in the list is selected it fires the following:
SqlLinks.SelectParameters("CategoryID").DefaultValue = ddlCategories.SelectedValue
dlLinks.DataBind()

The sqldatasource for the datalist runs a stored procedure (below)

sp_GetLinks (@.CategoryID ?) AS

select * from links where category = @.category

My question is, what should @.Category be declared as if the category column in the table is a uniqueidentifier? And what conversion do I need to do I just can't work it out, as I keep getting the following error:

Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.

Source Error:

Line 5: Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCategories.SelectedIndexChanged
Line 6: SqlLinks.SelectParameters("CategoryID").DefaultValue = ddlCategories.SelectedValue
Line 7: dlLinks.DataBind()
Line 8: End Sub
Line 9: End Class


Source File:C:\Documents and Settings\Karl Walls\My Documents\My Webs\AFRA\links.aspx.vb Line:7

Stack Trace:

[SqlException (0x80131904): Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +177
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +68
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2305
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
System.Data.SqlClient.SqlDataReader.get_MetaData() +62
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +294
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1021
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +314
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +20
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +107
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +10
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1659
System.Web.UI.WebControls.BaseDataList.GetData() +53
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +267
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +56
System.Web.UI.WebControls.BaseDataList.DataBind() +62
links.DropDownList1_SelectedIndexChanged(Object sender, EventArgs e) in C:\Documents and Settings\Karl Walls\My Documents\My Webs\AFRA\links.aspx.vb:7
System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +75
System.Web.UI.WebControls.DropDownList.RaisePostDataChangedEvent() +124
System.Web.UI.WebControls.DropDownList.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +7
System.Web.UI.Page.RaiseChangedEvents() +138
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4507

Try to modify the stored procedure as following:

alter proc sp_GetLinks @.Category sql_variant AS
select * from links where category =convert(uniqueidentifier,@.category)
go

|||

Thanks for the reply, before I saw it i removed this line

SqlLinks.SelectParameters("CategoryID").DefaultValue = ddlCategories.SelectedValue

and it worked fine

Sunday, March 11, 2012

Controlling Crystal Reports 9.0 Grids with VB

Hello,
I'm new to Crystal reports and am finishing up my first vb app. I need to be able to control the "Draw Custom Line" property of the Crystal Reports grid within VB 6.0. Does anyone know the Grid property I use in VB to control this?
Thanks so much!
Tricia =)aha! After a full day of searching for the answer, I think I found a comparable solution to this problem. =)

Solution: Split Dual Axis Grid
- Bottom axis range from x to alert level
- Upper axis range from alert level to x

Pros:
- The alert level line can be placed on the grid and it can be a variable amount calculated in VB so that we can normalize the data appropriately.

Cons:
- the grid must have 2 data points in order to have the split axis option available. The problem with this is that we need to show the marker for each point in the event of a first time sampling and only one level to show on the grid. I am using the alert level for the second data point and so the markers are showing only the alert level line, but it still looks a bit funky, but at least I have the line!!!

Wednesday, March 7, 2012

Context Class in AS 2005 Stored Procedure

We are trying to use the CurrentTuple property of the Context Class available in the assembly Microsoft.AnalysisServices.AdomdServer. The CurrentTuple property is documented in the standard AS2005 doc (see http://msdn2.microsoft.com/en-US/library/ms175329.aspx). However this seems not available in the class definition. The only property available are

public static CultureInfo ClientCultureInfo

public static CubeCollection Cubes

public static CubeDef CurrentCube

public static string CurrentDatabaseName

public static MiningModel CurrentMiningModel

public static string CurrentServerID

public static bool ExecuteForPrepare

public static MiningModelCollection MiningModels

public static MiningServiceCollection MiningServices

public static MiningStructureCollection MiningStructures

public static int Pass

Any suggestion?

Thanks a lot.

Riccardo

Hi Riccardo,

Looks like there are inconsistencies in BOL documentation - the link below doesn't list CurrentTuple. But this entry in Chris Webb's blog may help - it shows how to find the current member on each attribute hierarchy of the CurrentCube:

http://spaces.msn.com/cwebbbi/blog/cns!7B84B0F2C239489A!586.entry

>>

The first problem I tried to solve was this: how do you return the name of the currentmember on all dimensions in your cube in a query?

>>

http://msdn2.microsoft.com/en-us/library/microsoft.analysisservices.adomdserver.context_members.aspx

>>

Context Members

Provides the execution context for the stored procedure.

The following tables list the members exposed by the Context type.

Public Properties

Name Description ClientCultureInfo Gets the culture for the current client. Cubes Gets a collection of cubes that are available in the current database or context. CurrentCube Gets the current cube. CurrentDatabaseName Gets the current database name for the current session. CurrentMiningModel Gets the current mining model. CurrentServerID Gets the server identifier (server\instance) for the current session. ExecuteForPrepare Gets a value that indicates whether the stored procedure is being called for preparation purposes. MiningModels Gets the mining models in the current database. MiningServices Gets the mining services in the current database. MiningStructures Gets the mining structures in the current database. Pass

Gets the pass number that the user-defined function (UDF) or stored procedure is running under.

>>

|||

Thanks a lot, Deepak.

Riccardo