.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to convert System.Type to Data.DbType?

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :Windows Application
Hi,Is it possible to convert a System.Type to Data.DbType (this is unfortunately an enumaeration)?Thanks, Rainer.

View Complete Post

More Related Resource Links

The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must



This is frustrating, and I don't know how to solve it.

I have a strange problem. I am adding a LinqDatasource object, and set the context:

        protected void LinqDataSource_ContextCreating(object sender, LinqDataSourceContextEventArgs e)
            e.ObjectInstance = new KaruselaDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

Then I get this error:
The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


On web.config I already have this:
<add assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?


System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlCli

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=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Trusted_Connection = true" Dim connectionString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=TimeSheet;Integrated Security=SSPI"   I am not running the webpage in a virtual directory but in C:\Inetpub\wwwroot\usercontrol 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:DemandThe type of the first permission that failed was:System.Data.SqlClient.SqlClientPermissionThe Zone of the assembly that fa

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? 

Cannot convert from 'int' to 'System.Data.OracleClient.OracleParameter' - Problem with OracleHel

Hi I downloaded the OracleHelper.cs & I use VisualStudio 2008,I'm suppose to pass values to a stored procedure which accepts 2 parametersWhen i pass from codebehind it says,Cannot convert from 'int' to 'System.Data.OracleClient.OracleParameter'Cannot convert from 'string' to 'System.Data.OracleClient.OracleParameter'The best overloaded method match for 'DataWrapper.ExecuteNonQuery(string, System.Data.CommandType, string, params System.Data.OracleClient.OracleParameter[])' has some invalid argumentsI'm posting mycode,Using STORED PROCEDURE,OracleHelper.ExecuteNonQuery (con, CommandType.StoredProcedure, "sample", Int32.Parse(TextBox1.Text),TextBox2.Text); Plz help !______________________________________If possible,  tell me a solution for this error too !http://forums.asp.net/t/1598804.aspx

Data Type Convert problem?

1/2 is inputed by user, I hope to get the result 0.5, but both Method1 and Method2 get the result 0 How can I do? Thanks! BTW, I can't require user to input 1.0/2.0      Method1:     double my = 1/2;Method2:     double my = Convert.ToDouble(1/2);  

In Reporting Services: Request for the permission of type 'System.Data.SqlClient.SqlClientPermissio

Hello all,In Reporting Services through http://myserver/mydbinstance/Pages/Report.aspx blah de blah blah, I get this error:Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.Actually, the report runs just fine, but some fields had the famous #Error in them. I put some old fashioned debug in my report to TRY, CATCH, END TRY and get the problem to the report so that I could see this report finally run in production. Yes, it runs just fine in VS2005. I have custom code in the report code window that does its own custom connection to an SQL database through "System.Data.SqlClient.SqlConnection" and "System.Data.SqlClient.SqlCommand" to pull in data that is not part of any of the datasources in the report. When I execute the report through the Report Manager or Report site under IIS, the report will run, but I get these errors in every field that uses functions to populate the data.I have searched the web for 3 days now, and the best answers involve using either CASPOL or the Microsoft .NET Framework 2.0 Configuration wizard in Administrative Tools on the server. (I understand that the wizard does the same thing as CASPOL, just through a GUI.) I have followed those steps, but still get the error.I do not know what I need to do to make these DLLs th

DataSet does not support System.Nullable<>. at System.Data.DataColumn.set_DataType(Type value)

Hi All, I'm populating array of objects into DataTable.  One of the field is of type date and my be null..Can't seem to fix it. can anyone help.. Thanks,-----------------------------------------------------------Employees[] e = Service.GetEmployee();Util.ConvertToDataTable(e);-----------------------------------------------------------error:Unhandled Exception: System.NotSupportedException: DataSet does not support System.Nullable<>. at System.Data.DataColumn.set_DataType(Type value)    

An exception of type 'System.Data.SqlClient.SqlException' occurred and was caught


When the Stored procedure is executed through SQL Server Management Studio, its taking 23 seconds

When the same Stored proc is called through web app, its throwing below copied exception. It is noticed that when the data is more than 100k records this exception is thrown other wise expected records are shown in UI. Another stored proc from the same app returns over 150k records without any excetpion.

Can't conclude that the exception is in Stored proc, because it works from SQL Server Management studio, but throws below exception from Web app.

Your help is appreciated in resolving this issue.

An exception of type 'System.Data.SqlClient.SqlException' occurred and was caught.
10/17/2010 16:56:01
Type : System.Data.SqlClient.SqlException, System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
Source : .Net SqlClient Data Provider
Help link : 
Errors : System.Data.SqlClient.SqlErrorCollection
Class : 11
LineNumber : 0
Number : -2
Procedure : 
Server : XXXXX
State : 0
ErrorCode : -2146232060
Data : System.Collection

Unable to convert type System.String to System.Web.DynamicData.MetaTable



I am encountering the problem  "Unable to convert type System.String to System.Web.DynamicData.MetaTable" when I hit one of the tables for List.aspx.  It is using the DynamicData/PageTemplates/List.aspx and this error is not happening in other tables.

It is happening on the line

GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));

If you have any leads, please let me know.



Unable to cast object of type 'System.Data.SqlClient.SqlCommand' to type 'System.IConvertible'.


















System.Data.SqlClient.SqlException: Error converting data type nvarchar to datetime.


 Hi All,

I have recently moved a ASP.NET webserver from windows XP to
windows server 2008.
The website runs fine apart from anywhere that pulls a date
or uses the date from a JS date picker etc.

The error I am receiving is:

System.Data.SqlClient.SqlException: Error converting data type nvarchar to datetime.

Source Error:

Line 79:         cmd1.Parameters.AddWithValue("@EndDate", lblSearch2.Text);
Line 80:         conn.Open();
Line 81:         SqlDataReader reader = cmd1.ExecuteReader();
Line 82:         if (reader.HasRows)
Line 83:         {

Source File: c:\inetpub\wwwroot\folderx\pagex.aspx.cs    Line: 81

Stack Trace:

[SqlException (0x80131904): Error converting data type nvarchar to datetime.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849003
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject s

Is it possible SQLXML to accept the Base64Binary data type and convert it back to binary to a 'ntex


Hi, I am trying to pass to SQLXML ("SQLXMLBulkLoad.SQLXMLBulkload.4.0") an XSD schema to be able to accept the Base64Binary data type and convert it back to binary to a 'ntext' type field(Due to a legacy DB that sore some Binary data at a 'ntext' field at SQL Server)

I have try the following without success:

'<xsd:attribute name="Mybase64field" type="xsd:base64Binary" sql:datatype="image" />'

Is this possible?

Cannot implicitly convert type 'System.Web.UI.WebControls.TreeNode' to 'System.Xml.XmlNode



I bind xml to treeview and select the node.I write code as

XmlNode xnParent = TreeView1.SelectedNode.Parent;
        XmlNode xnchild = TreeView1.SelectedNode;

But i got error these places.

Error    1    Cannot implicitly convert type 'System.Web.UI.WebControls.TreeNode' to 'System.Xml.XmlNode'    E:\SVN_WORK1\Projects\Server\VegaFABSWeb\Admin\DataDictionary.aspx.cs    36    28    E:\...\VegaFABSWeb\


Rama Krishna

Crawl Error - Error in the Site Data Web Service. (Exception of type 'System.OutOfMemoryException'


I have a Sharepoint site that includes a WIki library.  Recently searches have stopped returning any hits from the Wiki pages.  (Search hits from documents and discussions are correctly returned.)  When I check the crawl log from Shared Services Admin site, I see the following error every time a crawl is performed:



Error in the Site Data Web Service. (Exception of type 'System.OutOfMemoryException' was thrown.)


The URL above is part of the Wiki library.  When I look at the raw Sharepoint logs, I see the following entries every time a crawl is performed:


11/26/2007 05:01:50.93  mssdmn.exe (0x1F98)                      0x1368 Search Server Common           MS Search Indexing             7hp2 Monitorable EnumerateListFolder fail. error 2147755542, strWebUrl http://cao.tfn.com/Caopedia, strListName {e9acf8e9-f23f-4afd-b8e9-6eaf6b0101db}, strFolder  
11/26/2007 05:01:50.93  mssdmn.exe (0x1F98)                      0x1368 Search Server Com

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

Specifications : VS 2008 & SQL 2005 Express
Unable to cast object of type 'System.Data.DataSet' to type 'DataSet'.
I'm getting this error in cliend app, while passing values to the wcf service(iis),
WCF Sevice code
  public DataSet ListofAccounts(string custidno)
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStrWestSideBank"].ConnectionString);
    SqlDataAdapter da = new SqlDataAdapter("select * from AccountDetails where vCustIdentityNo ='" + custidno + "'", con);
    DataSet ds = new DataSet();
    da.Fill(ds, "AccountDetails");
    return ds;
I'm unable to get this, i tried in many ways but no use, please help me. Follwing is the code,of button click event 
   ServiceReference1.ServiceClient svcobj = new

System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPerm


Good Day all,

Having an issue with an outside user accessing my IIS7 box. I do not have this problem when running the website from my host machine. I found this post: Http://forums.asp.net/t/1371394.aspx. I assure you that this is not a solution because I am not storing any of my files on a network share. 

What do you think my approach should be. 

I already have read rights to IIS user to my BIN folder. 

Thanks for the help. 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend