The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.

 Hi all,

When i run my project on my own computer, it works fine. But when i deploy it to server, it gives me this error.

I can run my other dts and sp, but i get this error on this..

The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.



I googled it but could not find a solution. 

How can i solve this problem? 

5
sourvil
10/8/2007 12:04:57 PM
asp.net.object-datasource 16182 articles. 0 followers. Follow

12 Replies
1904 Views

Similar Articles

[PageSpeed] 57

Hello sourvil,

I'm not sure what the problem is. The following thread explains how you can find out more about the error that is reported: http://blogs.infosupport.com/martijnb/archive/2006/01/27/3582.aspx

Jeroen Molenaar.


--------------------------------
Jeroen Molenaar.
0
jeroenm
10/8/2007 1:13:08 PM

 

Thanks for your reply but i developed it on my Xp machine (framework 2.0) and also our 2003 server machine has framework 2.0.

I can load dataset from other Sp from same sqlserver but on this Sp, i got this error. 

 

Any idea? 

0
sourvil
10/8/2007 1:23:45 PM

Can you add some code of the data layer?

Jeroen Molenaar.


--------------------------------
Jeroen Molenaar.
0
jeroenm
10/8/2007 2:16:58 PM

 I use just this command line in my Business Layer.

SqlHelper.ExecuteScalar(ConnectionNames.ErpConnection, "sp_invoiceprocess_format1", InvoiceDetails); 

And i can run several Dts and SP from same (Microsoft) SqlHelper.cs class. And i get this error only for this Sp.

And we don't have SqlServer installed on the server which we publish the website. I get data from other servers.

 Any idea?

 

Regards.. 

0
sourvil
10/9/2007 6:16:44 AM

The SqlHelper class is not the problem then. 

Is this the only command executed with the ConnectionNames.ErpConnection, e.g. is the syntax correct of the connectionstring?

Does the SP executes on the SQL server directly, e.g. is you SP correct?

Is the executescalar correct, e.g. do you want only one result returned from the SP?

Jeroen Molenaar.


--------------------------------
Jeroen Molenaar.
0
jeroenm
10/9/2007 7:13:00 AM

 Hi jeroenm,

All things work succesfully on my local Xp computer. The problem exists on the server which i want to publish this site. I can't think of any solutions when other sp and dts work correctly but this fails.

 

Regards.. 

0
sourvil
10/9/2007 8:47:20 AM

sourvil:
I get data from other servers.

What do you mean with this?

And do you have another DTS/SP command in the application in the published website using the ErpConnection, that is working correctly?

Tough nut to crackSmile


--------------------------------
Jeroen Molenaar.
0
jeroenm
10/9/2007 9:17:26 AM

We got other Sql servers and i can get data from them Smile

Also i can get data using ErpConnection by other Dts or Sp correctly.

 Something weird?

 

Regards..
 

0
sourvil
10/9/2007 10:40:36 AM

sourvil:
Something weird?

Yes, you can say that!

Have you tried to execute another sp than sp_invoiceprocess_format1 from the statement that gives the error? Can it be a grant issue on SQL-server with the sp?

I ran out of suggestions, sorry.

Jeroen.


--------------------------------
Jeroen Molenaar.
0
jeroenm
10/9/2007 12:40:25 PM

 Yeap, i tried and no error.

Thank you very much for your suggestions.

 

And noone can help me? 

0
sourvil
10/10/2007 9:39:31 AM

 No help?

0
sourvil
10/15/2007 5:51:00 AM

I'm lost, sorry Sad


--------------------------------
Jeroen Molenaar.
0
jeroenm
10/15/2007 7:17:33 AM
Reply:

Similar Artilces:

'TypeConverter' is unable to convert 'System.Data.SqlClient.SqlConnection' to 'System.Data.SqlClient.SqlConnection'.
Hey, I was hoping someone could shed some light on this error for me. I am using the TypeConverter in the System.ComponentsModel Namespace, and when I attempt to take an object, which in this case is a SQLConnection, and perform a TypeConvert (code example below) I get the following error: Error: ---------------------------------------------------------------------------- 'TypeConverter' is unable to convert 'System.Data.SqlClient.SqlConnection' to 'System.Data.SqlClient.SqlConnection'. ---------------------------------------------------------------------------- ...

Unable to cast object of type 'System.Boolean' to type 'System.Data.SqlClient.SqlParameter'.
In my code this doesn't work:prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2I get the error:Unable to cast object of type 'System.Boolean' to type 'System.Data.SqlClient.SqlParameter'. But this does: prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int)prms(0).Value = 2Any reason why?  You code prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2 do evaluation: 1. if New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2, the result is Yes or No, 2. prms(0) =...

Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'.
I am tring to retieve a single node from my BLL code which retrieve one instane of Repot object:DataView dv = (DataView)objBoutPrep.Select();I am getting error:Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'. The BLL code returns onle one object and not a list of objects.Please help Client code: <asp:ObjectDataSource ID="objBoutPrep" runat="server" SelectMethod="GetRByID" UpdateMethod="UpdateT" TypeName="MB.K.BLL.G.Report"> <SelectParameters> <asp:Query...

Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'.
what is my problem? I'm working with GridView for sorting The error message is that "Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'".... Dim m_DataTable As DataTable = GridView1.DataSource How can I change the code above?   Well let's see, if your DataSource is a DataView, you can get its associated DataTable object using the .Table property: Dim m_DataTable As DataTable = GridView1.DataSource.Table or in a land of strict typing:  Dim m_DataTable As DataTable = CType(GridView1.DataSource, System.Data.DataView).Table   Hope tha...

Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'.
When I click the sort hyperlink, I got this error mesg: Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'.  in line 5.How do I fix this? Thanks. 1 Protected Sub GVCRlisting_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GVCRlisting.Sorting 2 GridViewSortExpression = e.SortExpression 3 Dim pageIndex As Integer = GVCRlisting.PageIndex 4 5 GVCRlisting.DataSource = SortDataTable(GVCRlisting.DataSource, False) 6 GVCRlisting....

Unable to cast object of type 'System.Data.Common.DataRecordInternal' to type 'System.Data.DataRowView'.
Hi... I have a ListView which is nested in the ItemTemplate of another ListView. If a "status" value in the inner ListView = 1, then I'd like to hide the "Add to cart" link. However, the inner ListView's ItemDataBound event results in the error: "Unable to cast object of type 'System.Data.Common.DataRecordInternal' to type 'System.Data.DataRowView'." I've thoroughly searched the forums, but have not found a solution to this seemingly straightforward problem. Here is the code; the error occurs at line 8. 1 protected void L...

Unable to cast object of type 'System.String' to type 'System.Data.DataRowView'
Hi, I am having this problem: Unable to cast object of type 'System.String' to type 'System.Data.DataRowView'I have two repeaters: One is for a list of terms and the other show the definition. What I am trying to do is, highlight the selected term.Here is the relevant code which has this error:private Color SetButtonBackColor(object dataItem){ Response.Write("<br />In SetButtonBackColor Function"); Response.Write("<br>dataItem in SetColor is: " +(string)((DataRowView)dataItem)["TermIndex"]); string _initial =  (string) ((DataRowView)dataItem)["TermIndex"]; &n...

Unable to cast object of type 'System.IO.FileInfo' to type 'System.Data.DataRowView'.
This code below: Dim DomainVariable As String DomainVariable = Session("Domain")   If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem ThenDim FileRow As DataRowView = e.Item.DataItem Dim FileLink As HyperLink = e.Item.FindControl("FileHyperLink")Dim FileName As String = FileRow("Name")FileLink.NavigateUrl = String.Format("http://{0}/{1}", DomainVariable, FileName) FileLink.Text = FileRow("Name") End If IS GENERATING THIS ERROR............... Unable to cast object of type 'System.IO.Fil...

'Sybase.Data.AseClient.AseConnection.DriverVersion' threw an exception of type 'System.TypeInitializationException'
'Sybase.Data.AseClient.AseConnection.DriverVersion' threw an exception of type 'System.TypeInitializationException' This is an error which I am getting while instantiating AseConnection. Can I get help on this exception. I am using C# in Visual Studio 2005. I checked the version in the C:\Program Files\Sybase\OC12_5_1\ADO.NET\dll folder of Sybase.Data.AseClient.dll and sybdrvado11.dll and copied these dlls to my application's bin folder. The versions are the same. Still I am getting the above exception. Whats this code look like? Are you sure both DLLs are sa...

SqlDataSource.Select Error: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.
I am trying to use the select statement to put a field from my database using a SqlDataSource named 'FileBase.' 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:...

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'. Descri...

A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Hi, 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); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "dbo.rqryTradesPRR"; cmd.Parameters.Add("@COBDate"...

A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
I'm trying to pull data from database using a stored procedure to return to an autocomplete extender. It all worked fine with one stored procedure but not with the second one, which has exactly the same SQL code behind it...Ok here is the code from my web service:    Public Function getAutocompleteTitles(ByVal prefixText As String, ByVal count As Integer) As String()        Dim titelAdapter As moviesetsTableAdapters.SelectMoviesetsByTitleTableAdapter = New moviesetsTableAdapters.SelectMoviesetsByTitleTableAdapter    &n...

Error:first chance exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
hi all, I have a stored procedure to insert reecords on multiple table and when use this in asp.cs, I got this error:-   first chance exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll. Here is my sp             create procedure userRegistration ( @FirstName nvarchar(50), @LastName nvarchar(50), @EmailId varchar(100), @Password nvarchar(50), @CreationDate nvarchar(50), @EffectiveDate nvarchar(50), @AddressLine1 nvarchar(50), @City nvarchar(50), @State nvarchar(50),...

Web resources about - The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. - asp.net.object-datasource

Resources last updated: 12/14/2015 4:14:11 PM