Unable To Cast Object Of Type 'System.String' To Type 'System.Web.UI.WebControls.Parameter'.

I'm getting this error on a vb.net page the needs to execute two separate stored procedures.  The first one, is the main insert, and returns the identity value for the ClientID.  The second stored procedure inserts data, but needs to insert the ClientID returned in the first stored procedure.  What am I doing wrong with including the identity value "ClientID" in the second stored procedure? 

Unable to cast object of type 'System.String' to type 'System.Web.UI.WebControls.Parameter'. 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.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Web.UI.WebControls.Parameter'.

Source Error:

Line 14: If li.Selected Then
Line 15: InsertClientCompanyType.InsertParameters("CompanyTypeID").DefaultValue = li.Value
Line 16: InsertClientCompanyType.InsertParameters("ClientID") = ViewState("ClientID")
Line 17:
Line 18:

Source File: C:InetpubwwwrootIntranetExternalAppsNewEmploymentClientNewClient.aspx.vb    Line: 16

Here is my code behind... What am I doing wrong with grabbing the ClientID from the first stored procedure insert? 


Protected Sub InsertNewClient_Inserted(ByVal sender As Object, ByVal e As SqlDataSourceStatusEventArgs)
ClientID.Text = e.Command.Parameters("@ClientID").Value.ToString()
ViewState("ClientID") = e.Command.Parameters("@ClientID").Value.ToString()
End SubProtected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click
For Each li As ListItem In CompanyTypeID.Items

If li.Selected Then
InsertClientCompanyType.InsertParameters("CompanyTypeID").DefaultValue = li.Value
InsertClientCompanyType.InsertParameters("ClientID") = ViewState("ClientID")
End If
End Sub

View Replies


SqlDataSource.Select Error: Unable To Cast Object Of Type 'System.Data.DataView' To Type 'System.String'.

I am trying to put the data from a field in my database into a row in a table using the SQLDataSource.Select statement. I am using the following code: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'" myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)But when I run the code, I get the following error:Server Error in '/YorZap' Application. Unable to cast object of type 'System.Data.DataView' to type 'System.String'. 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.InvalidCastException: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.Source Error: Line 54: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'"
Line 55: 'myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments).GetEnumerator.Current, String)
Line 56: myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)
Line 57:
Line 58: filesTable.Rows.Add(myDataRow)Source File: D:YorZapdir_list_sort.aspx    Line: 56 Stack Trace: [InvalidCastException: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.]
ASP.dir_list_sort_aspx.BindFileDataToGrid(String strSortField) in D:YorZapdir_list_sort.aspx:56
ASP.dir_list_sort_aspx.Page_Load(Object sender, EventArgs e) in D:YorZapdir_list_sort.aspx:7
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3743
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210 Please help me!

View Replies View Related

Unable To Cast Object Of Type 'System.DateTime' To Type 'System.String'.

 Hi,      I got this field (dateSubmitted) having a data type of DateTime but I receive this error "Unable to cast object of type 'System.DateTime' to type 'System.String'."       All value for dateSubmitted field are 12/27/2007 12:00:00 AM. cheers,imperialx 

View Replies View Related

Unable To Cast COM Object Of Type 'System.__ComObject' To Class Type 'System.Data.SqlClient.SqlConn

Dear all,

I am stuck with a SSIS package and I can€™t work out. Let me know what steps are the correct in order to solve this.
At first I have just a Flat File Source and then Script Component, nothing else.


[Script Component [516]] Error: System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.SqlClient.SqlConnection'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface. at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.HandleUserException(Exception e) at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.AcquireConnections(Object transaction) at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostAcquireConnections(IDTSManagedComponentWrapper90 wrapper, Object transaction)

Script Code (from Script Component):

' Microsoft SQL Server Integration Services user script component
' This is your new script component in Microsoft Visual Basic .NET
' ScriptMain is the entrypoint class for script components

Imports System
Imports System.Data.SqlClient
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

Public Class ScriptMain
Inherits UserComponent

Dim nDTS As IDTSConnectionManager90
Dim sqlConnecta As SqlConnection
Dim sqlComm As SqlCommand
Dim sqlParam As SqlParameter

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Dim valorColumna As String
Dim valorColumna10 As Double

valorColumna = Row.Column9.Substring(1, 1)

If valorColumna = "N" Then
valorColumna10 = -1 * CDbl(Row.Column10 / 100)
valorColumna10 = CDbl(Row.Column10 / 100)
End If

Me.Output0Buffer.PORCRETEN = CDbl(Row.Column11 / 100)
Me.Output0Buffer.IMPRETEN = CDbl(Row.Column12 / 100)
Me.Output0Buffer.EJERCICIO = CInt(Row.Column2)
Me.Output0Buffer.CODPROV = CInt(Row.Column7)
Me.Output0Buffer.MODALIDAD = CInt(Row.Column8)
Me.Output0Buffer.NIFPERC = CStr(Row.Column3)
Me.Output0Buffer.NIFREP = CStr(Row.Column4)
Me.Output0Buffer.NOMBRE = CStr(Row.Column6)
Me.Output0Buffer.EJERDEV = CDbl(Row.Column13)

With sqlComm
.Parameters("@Ejercicio").Value = CInt(Row.Column2)
.Parameters("@NIFPerc").Value = CStr(Row.Column3)
.Parameters("@NIFReP").Value = CStr(Row.Column4)
.Parameters("@Nombre").Value = CStr(Row.Column6)
.Parameters("@CodProv").Value = CInt(Row.Column7)
.Parameters("@Modalidad").Value = CInt(Row.Column8)
.Parameters("@ImpBase").Value = valorColumna10
.Parameters("@PorcReten").Value = CDbl(Row.Column11 / 100)
.Parameters("@ImpReten").Value = CDbl(Row.Column12 / 100)
.Parameters("@EjerDev").Value = CDbl(Row.Column13)

End With

End Sub
Public Overrides Sub AcquireConnections(ByVal Transaction As Object)

Dim nDTS As IDTSConnectionManager90 = Me.Connections.TablaMODELO80
sqlConnecta = CType(nDTS.AcquireConnection(Nothing), SqlConnection)

End Sub
Public Overrides Sub PreExecute()

sqlComm = New SqlCommand("INSERT INTO hac_modelo180(Ejercicio,NIFPerc,NIFReP,Nombre,CodProv,Modalidad,ImpBase,PorcReten,ImpReten,EjerDev) " & _
"VALUES(@Ejercicio,@NIFPerc,@NIFReP,@Nombre,@CodProv,@Modalidad,@ImpBase,@PorcReten,@ImpReten,@EjerDev)", sqlConnecta)
sqlParam = New SqlParameter("@Ejercicio", Data.SqlDbType.SmallInt)
sqlParam = New SqlParameter("@NIFPerc", Data.SqlDbType.Char)
sqlParam = New SqlParameter("@NIFReP", Data.SqlDbType.Char)
sqlParam = New SqlParameter("@Nombre", Data.SqlDbType.VarChar)
sqlParam = New SqlParameter("@CodProv", Data.SqlDbType.TinyInt)
sqlParam = New SqlParameter("@Modalidad", Data.SqlDbType.SmallInt)
sqlParam = New SqlParameter("@ImpBase", Data.SqlDbType.Decimal)
sqlParam = New SqlParameter("@PorcReten", Data.SqlDbType.Decimal)
sqlParam = New SqlParameter("@ImpReten", Data.SqlDbType.Decimal)
sqlParam = New SqlParameter("@EjerDev", Data.SqlDbType.Decimal)

End Sub

Public Sub New()

End Sub
Public Overrides Sub ReleaseConnections()
End Sub

Protected Overrides Sub Finalize()
End Sub
End Class

Thanks a lot for your help

View Replies View Related

@PARAM1 : Unable To Cast Object Of Type 'System.Data.SqlTypes.SqlInt32 To Type System.IConvertable

I get the following message in the vs2005 querybuilder when i do a preview:

SQL Execution Error.

Executed SQL statement: SELECT Schoolindex, Variant, VVSchool, [index], indincl, VVRuimtes, School FROM School WHERE (Schoolindex = @PARAM1)

Error Source: SQL Server Compact Edition ADO.NET Data Provider

Error Message: @PARAM1 : Unable to cast object of type 'System.Data.SqlTypes.SqlInt32 to type System.IConvertable'.

The same querypreview works fine without the parameter:

SELECT Schoolindex, Variant, VVSchool, [index], indincl, VVRuimtes, School FROM School WHERE (Schoolindex = 186)

Can anybody tell me why this is?
And tell me a way to get the tableadapter working?

Anne-Jan Tuinstra

View Replies View Related

Unable To Cast Object Of Type 'System.DBNull' To Type 'System.Byte[]'.

I have developed a custom server control for .NET Framework 2.0. The server control has a property named BinaryData of type byte[]. I marked this property to be data bindable. Now, I have varbinary(Max) type of field in my SQL Database and I have used SQLDataSource and bound this varbinary(Max) field with the property BinaryData (byte[]) of my control. It is working fine as long as the data value is not NULL. Now, In my control, I have handled the NULL value so that no Exception is thrown. Still, when I bind this property using the SQLDataSource, I get Error "Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'." I am not sure if I can do anything to stop this erro within my control. If it is not possible from the control, then what is the workaround that I can do in my ASPX page in order to stop this error ?
Thanks a lot in advance.

View Replies View Related

Unable To Cast Object Of Type 'System.Object' To Type 'System.Data.DataSet'.

hi i dont know how to do type casting.

this.Variables.ObjVariable this objVariables i have create in variable place below like this

Name:Variable datatype int32 values 0

Name: NumberofRowsdatatype int32 values 10000

Name: ObjVariable datatype Object

My code

public override void CreateNewOutputRows()



Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".

For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".


System.Data.OleDb.OleDbDataAdapter oLead = new System.Data.OleDb.OleDbDataAdapter();

//System.Data.Odbc.OdbcDataAdapter oLead = new System.Data.Odbc.OdbcDataAdapter();

//SqlDataAdapter oLead = new SqlDataAdapter();

System.Data.DataTable dt = new System.Data.DataTable();

DataSet ds = (DataSet)this.Variables.ObjVariable; // here i am getting error


ADODB.Record rs = new ADODB.Record();

oLead.Fill(ds, rs, "Variables");

foreach (DataRow row in dt.Rows)




Output0Buffer.Column = (int)row["Column"];

Output0Buffer.Column1 = row["Column1"].ToString();

Output0Buffer.Column2 = row["Column2"].ToString();





This is the error

Unable to cast object of type 'System.Object' to type 'System.Data.DataSet'.

at ScriptMain.CreateNewOutputRows()

at UserComponent.PrimeOutput(Int32 Outputs, Int32[] OutputIDs, PipelineBuffer[] Buffers)

at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PrimeOutput(Int32 outputs, Int32[] outputIDs, PipelineBuffer[] buffers)



View Replies View Related

Unable To Cast Object Of Type 'System.String' Error Help

Unable to cast object of type 'System.String' to type 'System.Web.UI.DataSourceSelectArguments'.
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.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Web.UI.DataSourceSelectArguments'. 
Hi, In my pageload i have data retriving from a page and i want it to load it in the GridView. i have GridView and SqlDataSource but when the page loads i am getting the above error. i am not sure what im doing wrong here. i tried different ways. but no luck Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Thenfp = CType(Context.Handler, Member)
'lblEmail.Text = fp.EMM.ToString
'this labelbox for Email address is under the Name'lblEmail.Text = fp.EmailAddress.ToString
 Dim conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("imacstestConnectionString").ConnectionString)
Dim cmd As SqlCommand = New SqlCommand("SELECT , [fname], [mname], [lname], [address], [city], [state], [zip], [phone] FROM [t_CustomerAcct] WHERE = @email", conn)cmd.Parameters.AddWithValue("@email", fp.EMM.ToString)
End If
End Sub

View Replies View Related

Unable To Cast Object Of Type 'System.Xml.XmlTextReaderImpl'

I'm getting the following error:  Unable to cast object of type 'System.Xml.XmlTextReaderImpl' to type 'System.Xml.XmlTextReader'. This works in .net 1.1 but having issues in the conversion to 2.0.
Public Function RunSPReturnXMLReader(ByVal strSP As String, ByVal ParamArray params() As SqlParameter) As System.Xml.XmlTextReader
Dim objHelperConnection As SqlConnectionobjHelperConnection = New SqlConnection(sConnect)Dim myXmlReader As System.Xml.XmlReader = objHelperCommand.ExecuteXmlReader()
RunSPReturnXMLReader = myXmlReader - GETTING ERROR HERE
End Function

View Replies View Related

Unable To Cast Object Of Type 'System.Char'

using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Collections;

public partial class UserDefinedFunctions
TableDefinition = "ObjID int,ObjCategoryID int,ObjValue nvarchar(400)",
DataAccess= DataAccessKind.Read)]

public static IEnumerable Obj_IDs(SqlInt32 Data_1, SqlInt32 Data_2, SqlInt32 Data_3)
using (SqlConnection conn = new SqlConnection("context connection=true"))
string sql;
case 1:
sql= @"Select Obj_ID, Obj_Categoy_ID, Obj_Value
from (select ObjA_ID as Obj_ID, Obj_Category_ID, Obj_Value from dbo.function_A(12,23))A,
(select ObjA_ID as Obj_ID, Obj_Category_ID, Obj_Value from dbo.function_A(15,27))B
Where A.ObjA_ID= B.ObjA_ID
and Obj_ID in (Select ObjB_ID from tbl_Object where Obj_CategoryID=10)";
sql = @"Select Obj_ID, Obj_Categoy_ID, Obj_Value from tbl_Object";

SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
return dt.Rows;
catch (Exception ex)
return "";


public static void Obj_Row(Object item, out int ObjID, out int ObjCategoryID, out string ObjValue)
DataRow row = (DataRow)item;
ObjID = Convert.ToInt32(row["Obj_ID"]);
ObjCategoryID = Convert.ToInt32(row["Obj_Categoy_ID"]);
ObjValue = row["Obj_Value"].ToString();


compile with no error. Call funtion from sql studio the error come ==>

Msg 6260, Level 16, State 1, Line 1
An error occurred while getting new row from user defined Table Valued Function :
System.InvalidCastException: Unable to cast object of type 'System.Char' to type 'System.Data.DataRow'.
at UserDefinedFunctions.Object_Row(Object item, Int32& ObjID, Int32& ObjCategoryID, String& ObjValue)
when I change SQL script to simple not "nested select" it work fine. How to get out of this kind of trouble????!!!!

View Replies View Related

Unable To Cast COM Object Of Type 'ADODB.CommandClass' To Interface Type 'ADODB._Command'

I have an application which runs successfully on a couple of my customer's machines but fails on a third. It seems to fail when opening the database:

Unable to cast COM object of type 'ADODB.CommandClass' to interface type 'ADODB._Command'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B08400BD-F9D1-4D02-B856-71D5DBA123E9}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=false; Initial Catalog=lensdb;Data Source = SQL

Before I got this error I was getting another problem (sorry didn't make a copy of that error's text) that made me think that adodb.dll simply wasn't loaded/registered. I got rid of that error by copying my adodb.dll onto the third machine and running gacutil /i. There is now an entry in winntassemblies for adodb.

Just in case you think it could be an obvious registry problem: when I started getting the current error I thought that maybe the registry needed updating and I merged the following lines into onto the target machine (from my dev machine):

Windows Registry Editor Version 5.00









but, no change alas.

All three machines are running Windows 2000.

Any advice would be appreciated.

Thanks in advance,


View Replies View Related

How To Fix Unable To Cast Object Of Type 'Microsoft.SqlServer.Management.Smo.Urn'

In Sql Server 2005, Sql Server Mangerment Studio 9.00.1399.00
I connected an user instance to the databases under .SQLEXPRESS(SqlServer 9.0.3042 -....)
when I right click on a table
and chose modify, or new table...
I get

TITLE: Microsoft SQL Server Management Studio
Unable to cast object of type 'Microsoft.SqlServer.Management.Smo.Urn' to type 'Microsoft.SqlServer.Management.Smo.Urn'. (SQLEditors)

same thing for views
What can I do to fix the problem? is there a patch?

btw script .... as seem to be erro free Error free is also View dependence,

View Replies View Related

Open SSIS Project Error: Unable To Cast COM Object Of Type

When I open up my existing SSIS project, I always get this error. Does anyone know what was wrong ?

TITLE: Microsoft Visual Studio

Unable to cast COM object of type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.PackageNeutralClass' to interface type 'Microsoft.SqlServer.Dts.Runtime.IObjectWithSite'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{FC4801A3-2BA9-11CF-A229-00AA003D7352}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).

View Replies View Related

System.Security.SecurityException: Request For The Permission Of Type 'System.Data.SqlClient.SqlClientPermission, System.Data

I have created a windows library control that accesses a local sql database

I tried the following strings for connecting

Dim connectionString As String = "Data Source=localhostSQLEXPRESS;Initial Catalog=TimeSheet;Trusted_Connection = true"

Dim connectionString As String = "Data Source=localhostSQLEXPRESS;Initial Catalog=TimeSheet;Integrated Security=SSPI"

I am not running the webpage in a virtual directory but in


and I have a simple index.html that tries to read from an sql db but throws

the error

System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.PermissionSet.Demand()
at System.Data.Common.DbConnectionOptions.DemandPermission()
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,

etc etc

The action that failed was:
The type of the first permission that failed was:
The Zone of the assembly that failed was:

I looked into the .net config utility but it says unrestricted and I tried adding it to the trusted internet zones in ie options security

I think that a windows form connecting to a sql database running in a webpage should be simple

to configure what am I missing?

View Replies View Related

Request For The Permission Of Type 'System.Web.AspNetHostingPermission, System, Version=, Culture=neutral, PublicKeyToken

Reporting services is configured to use a custom security extension in the following Environment.

Windows xp

IIS 5.0

when i go to http://servername/reports , the UIlogon.aspx page loads fine and i enter username and password. but i get logon failed.

when i go to http://servername/reportserver , the logon.aspx does not load and i get the following error message :

"Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

any idea ? .


View Replies View Related

Msg 6522, Level 16, State 2, Line 1: System.InvalidCastException: Conversion From Type 'SqlBoolean' To Type 'Boolean' Is Not Val

I created a function called Temperature in VB to be used as a UDF in SQL2005. I get the error listed below. Any thoughts?

CREATE FUNCTION Temperature(@FluidName SQL_variant, @InpCode SQL_variant, @Units SQL_variant, @Prop1 SQL_variant, @Prop2 SQL_variant)


AS EXTERNAL NAME Fluids_VB6.[Fluids_VB6.FluidProperties.Fluids].Temperature

Then ran function:

select dbo.temperature('R22','t','e','225.6','0')

Got this:

Msg 6522, Level 16, State 2, Line 1

A .NET Framework error occurred during execution of user defined routine or aggregate 'Temperature':

System.InvalidCastException: Conversion from type 'SqlBoolean' to type 'Boolean' is not valid.


at Microsoft.VisualBasic.CompilerServices.Conversions.ToBoolean(Object Value)

at Fluids_VB6.FluidProperties.Fluids.Setup(Object& FluidName)

at Fluids_VB6.FluidProperties.Fluids.CalcSetup(Object& FluidName, Object& InpCode, Object& Units, Object& Prop1, Object& Prop2)

at Fluids_VB6.FluidProperties.Fluids.CalcProp(Object& FluidName, Object& InpCode, Object& Units, Object& Prop1, Object& Prop2)

at Fluids_VB6.FluidProperties.Fluids.Temperature(Object FluidName, Object InpCode, Object Units, Object Prop1, Object Prop2)



View Replies View Related

BC30311: Value Of Type 'System.Data.SqlClient.SqlDataReader' Cannot Be Converted To 'String'.

Does anyone know what the problem is?

Sub Page_Init(sender As Object, e As EventArgs)
Dim txtName As New TextBox()
Dim txtPart As New TextBox()
Dim txtEach As New TextBox()
Dim txtTotal1 As New TextBox()
Dim txtSubtotal As New TextBox()
Dim txtTax As New TextBox()
Dim txtShipping As New TextBox()
Dim txtTotal2 As New TextBox()

Dim prod_id As Integer
Dim id As Integer
id = Request.Querystring("prod_id")
txtName.Text = GetName(id).................this is the problem line


End Sub

I'm trying to populate dynamically rendered textbox's, how should I do that too?

View Replies View Related

Request For The Permission Of Type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, Pu

I created a .net console application within which I connect to a sql server (not local) as follows,

string conn_str = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=QuantEquitySql;Data Source=server name";

SqlConnection conn = new SqlConnection(conn_str);

Everything works fine when I run it from my computer. When I try to run it from a network share I get the following error,

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I am using Visual Studio 2005 and .Net framwork v2.0.50727.

Does anybody know a fix to this problem?


View Replies View Related

A First Chance Exception Of Type 'System.Data.SqlClient.SqlException' Occurred In System.data.dll

I've written this code multiple times now. But for the first time i get an error at the line underlined. My procedure runs perfectly when i execute it through Sql Query analyzer.
plzz help.. Its urgent and am unable to find the reason for this error "A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll"
Thanks !SqlConnection conn = new SqlConnection(DbConnectionString);
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "dbo.rqryTradesPRR";
cmd.Parameters.Add("@COBDate",SqlDbType.DateTime).Value = "2002-10-31 00:00:00.000" ;
SqlDataReader reader = cmd.ExecuteReader();
// have written something here

 Thanks in advance !

View Replies View Related

Cast From String 'OPEN' To Type 'Double' Is Not Valid.

Hi.. Please help me resolve this error "Cast from string 'OPEN' to type 'Double' is not valid.". Error here If CallStatus = 10 Then ....Code:Public Sub UpdateCallStatus()        Dim CALLID, RequestorID, CommentsFromITD, MessageFromITD, MessageToITD, CallStatus, strSQL As String        CALLID = Request.QueryString("CallID")        RequestorID = Session("USER_ID")        CommentsFromITD = lblcomments.Text        MessageFromITD = lblmessage.Text        MessageToITD = txt_desc.Text        CallStatus = Trim(Request.Form(ddl_callstatus.UniqueID))
        Dim ObjCmd As SqlCommand        Dim ObjDR As SqlDataReader
        Try            If CallStatus = 10 Then                strSQL = "UPDATE CALLS  SET STATUS_ID=" & CallStatus & " WHERE CALL_ID=  " & CALLID & ""                ObjCmd = New SqlCommand(strSQL, ObjConn)                ObjConn.Open()                ObjDR = ObjCmd.ExecuteScalar()                gbVariables.insertuserevents(CALLID, RequestorID, "Call Closed")                Response.Redirect("UserCallClosed.aspx")                ObjConn.Close()            Else                strSQL = "UPDATE CALLS  SET STATUS_ID=" & CallStatus & " WHERE CALL_ID=  " & CALLID & ""                ObjCmd = New SqlCommand(strSQL, ObjConn)                ObjConn.Open()                ObjDR = ObjCmd.ExecuteScalar()                ObjConn.Close()
                strSQL = "SELECT STATUS_LABEL  FROM STATUS WHERE STATUS_ID = " & CallStatus & ""                ObjCmd = New SqlCommand(strSQL, ObjConn)                ObjConn.Open()                ObjDR = ObjCmd.ExecuteScalar()                ObjConn.Close()
                gbVariables.insertuserevents(CALLID, RequestorID, CallStatus)                CallStatus = ""            End If        Catch ex As Exception            lblmsg.Text = ex.Message.ToString        End Try    End SubThanks...

View Replies View Related

Type Cast Error Converting From Integer To String

I am attempting to convert an integer value to a string using the Derived Column transformation with the following expression on the field:

prod_id is an integer. I was able to do this before however, in the past couple of days, this has failed with the following error:
"An error occurred while attempting to perform a type cast."

To my knowledge, I have not changed anything about this particular data flow within the past couple of days. I have verified that the value is coming in as an integer.

Any help would be greatly appreciated.

View Replies View Related

CS0266: Cannot Implicitly Convert Type 'object' To 'bool'. An Explicit Conversion Exists (are You Missing A Cast?)

Using OnSelected on the SqlDataSource----here is my currect code:private void On_Load(Object sender, SqlDataSourceCommandEventArgs e){if (e.Command.Parameters["@DueDate"].Value = "NULL"){e.Command.Parameters["@DueDate"].Value = "0000-00-00 00:00:00.000";}}
I am trying to change the value from  NULL(in a datetime field) to "0000-00-00 00:00:00.000" for use on the page.Any ideas, suggestions, or thoughts would be greatly appreciated!
,Gary"we truly fail, only when we quit."

View Replies View Related

How To Create A System Type Table/ Change User Table To System Table.

Is there any Posibility to change a User Table to System Table.

How to create one system table.

I am in Big mess that One of the Table I am using is in System Type.

I cant Index the same. Is there any Mistake we can change a user table to system table.....

View Replies View Related

'((System.Exception)($exception)).Message' Threw An Exception Of Type 'System.NotSupportedException'

Greetings everyone, I am attempting to build my first application using Microsofts Sql databases. It is a Windows Mobile application so I am using Sql Server Compact 3.5 with Visual Studio 2008 Beta 2. When I try and insert a new row into one of my tables, the app throws the error message shown in the title of this topic.
'((System.Exception)($exception)).Message' threw an exception of type 'System.NotSupportedException'

My table has 4 columns (i have since changed my FavoriteAccount datatype from bit to Integer)

Account type will either be "Checking" or "Savings" when a new row is added, the user will select what they want from a combo box.

Next is a snap shot of my startup form.

Where it says "Favorite Account: None" in the top panel, I am using a link label. When a user clicks "None" it will go to a account creation wizard, and set the first account as it's primary/favorite. As more accounts are added the user can select which will be his/her primary/favorite. For now I am just creating a sample account when the label is clicked in an attempt to get something working. Below is the code used.

private void lnkFavoriteAccount_Click(object sender, EventArgs e)


FinancesDataSet.BankAccountRow account = this.financesDataSet.BankAccount.NewBankAccountRow();

account.Name = "MyBank Checking Account";

account.AccountType = "Checking";

account.Balance = Convert.ToDecimal("15.03");

account.FavoriteAccount = 1;//datatype is an integer, I have changed it since I took the screenshot.

//The next three lines where added while I was trying to get this to work.
//I don't know if I really need them or not, I receive the error regardless if these are here or not.





the refreshDatabase() code is here:

private void refreshDatabase()



//Aquire a count of accounts the user has

int numAccounts = financesDataSet.BankAccount.Count;

//Loop through each account and see which one is the primary.

for (int num = 0; num != numAccounts; num++)

//Works ok in frmMain_Load, but when my lnkFavoriteAccount_click calls this, it throws the error.

if (this.financesDataSet.BankAccount[num].FavoriteAccount == 1)

//Display the primary account on our home page. User can click the link label & be taken to their account register.

this.lnkFavoriteAccount.Text = this.financesDataSet.BankAccount[num].Name.ToString();

this.lnkFavoriteFunds.Text = this.financesDataSet.BankAccount[num].Balance.ToString();





and my form_load code

private void frmMain_Load(object sender, EventArgs e)




So, when I click on the lnkFavoriteAccount label, and my new row gets added, the app stops at the following line in my DataSet.Designer


public byte FavoriteAccount {

get {

try {

return ((byte)(this[this.tableBankAccount.FavoriteAccountColumn]));


catch (global:ystem.InvalidCastException e) {
//Stops at the following line, this error was caused by 'if (this.financesDataSet.BankAccount[num].FavoriteAccount == 1)'

throw new global:ystem.Data.StrongTypingException("The value for column 'FavoriteAccount' in table 'BankAccount' is DBNull.", e);



set {

this[this.tableBankAccount.FavoriteAccountColumn] = value;



I have no idea what I am doing wrong, all of the code I used I retreived from Microsofts help documentation included with VS2008. I have tried used my TableAdapter.Insert() method and it still failed when it got to

if (this.financesDataSet.BankAccount[num].FavoriteAccount == 1)

in my refreshDatabase() method it still failed.

When I look, the data has been added into the database, it's just when I try to retreive it now, it bails on me. Am I retreiving the information wrong?

Thanks for any help you guys can offer.


View Replies View Related

System.Data.SqlClient.SqlException: The Conversion Of A Char Data Type To A Datetime Data Type Resulted In An Out-of-range Datetime Value.

After testing out the application i write on the local pc. I deploy it to the webserver to test it out. I get this error.

System.Data.SqlClient.SqlException: The conversion of a char data type to a
datetime data type resulted in an out-of-range datetime value.

Notes: all pages that have this error either has a repeater or datagrid which load data when page loading.

At first I thought the problem is with the date, but then I can see
that some other pages that has datagrid ( that has a date field) work
just fine.

anyone having this problem before?? hopefully you guys can help.


View Replies View Related

Could Not Load Type 'System.Data.SqlServerCe.SqlCeDataAdapter' From Assembly 'System.Data.SqlServerCe'


I am trying to make a mobile application work, but I get the following error. The operating system on Pocket PC is Microsoft® Windows Mobile„¢ 2003 Second Edition. Any ideas? Thanks in advance.

The followings are the error and my codes:

System.TypeLoadException was unhandled
Message="Could not load type 'System.Data.SqlServerCe.SqlCeDataAdapter' from assembly 'System.Data.SqlServerCe, Version=, Culture=neutral, PublicKeyToken=89845DCD8080CC91'."
at SQLMobile.Form1.Form1_Load()
at System.Windows.Forms.Form.OnLoad()
at System.Windows.Forms.Form._SetVisibleNotify()
at System.Windows.Forms.Control.set_Visible()
at System.Windows.Forms.Application.Run()
at SQLMobile.Form1.Main()


Private Sub FillGrid()

Dim filename As New String _

("Program FilesSQLMobilesqlmobile.sdf")

Dim conn As New SqlCeConnection("Data Source=" + filename)

Dim selectCmd As SqlCeCommand = conn.CreateCommand()

selectCmd.CommandText = "select Destination from flightdata"

Dim adp As New SqlCeDataAdapter(selectCmd)

Dim ds As New DataSet()


DataGrid1.DataSource = ds

End sub

View Replies View Related

'System.Web.NativeFileChangeNotification' To Type 'DecompressInitDelegate'.

I started getting this error, strangely, in SSRS when processing an updated report:

An error has occurred during report processing.

Cannot create a connection to data source 'AnalysisServices'.

Unable to cast object of type 'System.Web.NativeFileChangeNotification' to type 'DecompressInitDelegate'.

Has anyone seen this issue or know how to resolve it?

View Replies View Related

Function With A Parameter Of Type Object.


I would like to create a function that accepts a value of any type as parameter. I mean, it could receive a value of type int, datetime, char,...
In .net, I would use the type "object". Is there an equivalent for SQL server function ?



View Replies View Related

Cannot Convert Type 'int' To 'System.Data.DataView'

I have the following SqlDataSource in my page:<asp:SqlDataSource ID="sqlds" runat="server" ConnectionString="<%$ ConnectionStrings:cs %>"    SelectCommand="SELECT [Quest1], [Quest2], [Quest3], [Quest4], [Quest5] WHERE ([QuestID] = @QuestID)">    <SelectParameters>        <asp:Parameter Name="QuestID" />    </SelectParameters> In my code I get the following error: "Cannot convert type 'int' to 'System.Data.DataView'", I don't understand why I am getting this error because I am casting my SqlDataSource as type DataView when passing it to my DataView type.Code: protected void Chart(string record)    {        System.Data.DataView dv = (System.Data.DataView)sqlds.SelectParameters.Add("QuestID", System.TypeCode.Int32, record); //Error line       ...       ...       ...}If anyone could point me in the right direction I would be very grateful. 

View Replies View Related

Missing System Type Stored Procedure

Hi everyone,

I used DTS export to transfer tables, stored procedures, and etc...to a new database on the same SQL Server 7.0 machine. However, the System type stored procedures do not show up on the new database, only the user type stored procedure type show up.
Can some show me how to get my system type stored procedures to show up in the database?


View Replies View Related

SQLConnection Threw Exception Of Type System.InvalidOperationException

My SqlConnection is causing an error "sqlConn.ServerVersion threw an exception of type System.InvalidOperationException". Everything I have read seems to suggest that there is a problem with my SQLConnection parameters but as you can see from the commeted code below I have tried three different servers with four different configurations.  I am out of ideas on what is causing the error. 
Thanks - Amy
Here is a section of my code:
String sqlStmt = "Select [UserName], [Password], [Last], [First] from Contacts Where Login=@Uid AND Password=@Pwd";
SqlConnection sqlConn = new SqlConnection("Data Source=localhost;Initial Catalog=test;Integrated Security=SSPI;");//SqlConnection sqlConn = new SqlConnection("Data Source=pe2800;Initial Catalog=test;Integrated Security=SSPI;");//SqlConnection sqlConn = new SqlConnection("Data Source=HorizonDC02;Initial Catalog=test;Integrated Security=SSPI;");//SqlConnection sqlConn = new SqlConnection("Data Source=HorizonDC02;Initial Catalog=test;User ID=username;Password=password;");
SqlCommand sqlCmd = new SqlCommand(sqlStmt, sqlConn);sqlCmd.Parameters.Add("@Uid", SqlDbType.VarChar, 30).Value = uid;sqlCmd.Parameters.Add("@Pwd", SqlDbType.VarChar, 30).Value = pwd;sqlCmd.Connection.Open();

View Replies View Related

Type 'System.Data.SqlClient.SqlDataReader' Has No Constructors

I am getting the error below

View Replies View Related

How Do I Change The Type Of A Stored Procedure From User To System?

I built a database by using a generated script from the originaldatabase. It built the System Store Procedures as User type. How do Ichange them back to System type?

View Replies View Related

Copyrights 2005-15 www.BigResource.com, All rights reserved