.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

Cannot implicitly convert type

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net

        public SqlDataReader GetModelbyModelID(int modelID)
            Database db = DatabaseFactory.CreateDatabase();
            string sqlCommand = "GetModelbyModelID";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
            db.AddInParameter(dbCommand, "modelID", DbType.Int32, modelID);
            SqlDataReader dataReader = db.ExecuteReader(dbCommand);    ***********************
 return dataReader; }

I am getting the followind error????

Error    27    Cannot implicitly convert type 'System.Data.IDataReader' to 'System.Data.SqlClient.SqlDataReader'. An explicit conversion exists (are you missing a cast?)    E:\projects\models\App_Code\dataProfile.cs    780    40    E:\projects\models\

View Complete Post

More Related Resource Links

Cannot Implicitly Convert Type Ilist to List

Hi All, In the below code i get the Following Error, Cannot implicitly convert type 'System.Collections.Generic.List<Nous.nSpeckEnterprise.GetEnterpriseComponent_Result>' to 'System.Collections.Generic.IList<Nous.nSpeckEnterprise.Component>'. An explicit conversion exists (are you missing a cast?)   <br/> NSTTT_CRRISQ_TESTEntities entities = new NSTTT_CRRISQ_TESTEntities();<br/> IList<Component> Components = new List<Component>();<br/> var c = entities.GetEnterpriseComponent(componentId).ToList();<br/> <strong>Components = c;<br/> </strong> return Components;   Can anyone help me how to do teh cast.......Thanks  

error: cannot implicitly convert type 'string' to 'int?'

Hey guys,I am trying yo build the following class for which i get an error on the line this.id = e.id as cannot implicitly convert type 'string' to 'int?'. can anybody help me with it??many many Thanks,Chetan.using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Data.Linq;using System.Text;using System.Runtime.Serialization;using HsInternet.Data.DAL;namespace HsInternet.Data.BLL{    public class Baby    {        public int id { get; set; }        public string name { get; set; }        public string parents { get; set; }        public int gender { get; set; }        public string weight { get; set; }        public string length { get; set; }        public DateTime date { get; set; }        public DateTime time { get; set; }        public string image { get; set; }        public string ipa { get; set; }        public string ipb { get; set; }        public Baby()  &

cannot implicitly convert a type in a dll to the same type in the Service proxy.cs.


I got an error message, that said that cannot implicitly convert a type in a dll to the same type in the Service proxy.cs.  

I have a WCF solution. The solution has DAL, Service, Host, Client, UserControl projects etc.

In the service project, I defined:

    public class PatientAndAccount
        Patient patientRow;
        AccBa   accountRow;

        public Patient PatientRow
            get { return patientRow; }
            set { patientRow = value; }
        public AccBa AccountRow
            get { return accountRow; }
            set { accountRow = value; }

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

Cannot convert type 'object[]' to 'byte[]'


I am doing this .. and i want to convert object array to byte array. How should I do that?

Object[] myVal = um.myData;

Byte[] byteArray = (Byte[])myVal;

How to convert System.Type to Data.DbType?

Hi,Is it possible to convert a System.Type to Data.DbType (this is unfortunately an enumaeration)?Thanks, Rainer.

Unable to enter the product key in the Convert License Type page (textbox is read-only)

We installed both WSS and MOSS SP2 and had planned to follow the manual fix for the known issue that the patch unexpectedly activates a trial expiration.  However, the textbox to enter the product key is read-only.  We have tried accessing this page using the normal administrator credentials as well as the farm account; no success.The SP2 issue and manual fix is detailed here, http://support.microsoft.com/default.aspx/kb/971620We were able to experience this problem on a farm running the Feb 2007 cummulative patch (version so it's not related to the SP.  But running the SP increasing the need to find the fix.Any help is appreciated,J. Aqui

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);  

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.



Use the Convert License Type page to convert this installation to a licensed version.


I just rebuilt my entire farm and used the software I downloaded from MSDN.   When I try and type in my License key I can't type in the key box.  The OK button is greyed out and I am not able to type in my key into the Key field.  

I am using SharePoint 2007 SP2 on Windows 2008 64bit.  Why can't I change my key?

how to convert date type in SQL query output ?


In my database when anyone registers - By default the registration time is saved as UTC universal time zone.

But i want to display everything on the website in (GMT-05:00) Eastern Time (US & Canada)

I am using this SQL QUERY to display registration date:

SELECT TOP (5) Username, CustomerID,  RegistrationDate = CONVERT(VARCHAR(12),RegistrationDate,107)  FROM Customer ORDER BY RegistrationDate DESC

And, i am displaying it like this:

<asp:Label ID="nameLabeldate" runat="server" Text='<%# Eval("RegistrationDate") %>' />

The problem is the output is getting displayed as : 10/20/2010 1:36:01 PM

I know RegistrationDate is datetime stamp that's why i am getting output in this format.

But i want to display RegistrationDate as: Oct 20, 2010 at 1:36pm -> according to (GMT-05:00) Eastern Time (US & Canada) ORDER BY RegistrationDate in Desc (top most will be last registered user)

I need help with sql query by which i should be able to accoplish my desired output..please help...

How to convert image class object to byte type in order to insert database


I am trying to resize images after uploading and than inserting them into my database.

Dim newMainImage As System.IO.Stream = System.IO.Stream.Null
resizedMainImage.Save(newMainImage, jgpEncoder, myEncoderParameters)
Dim newMain As Image = Image.FromStream(newMainImage)

I was able to resize it however I couldnt find a way to convert image object to byte() in order to

I need something like

Dim ImageContent(newMain.ContentLength - 1) As Byte

newMain.InputStream.Read(ImageContent, 0 , newMain.ContentLength)

I need to convert image object to a file type in order to get its contentlenght and use .inputStream.Read function. Or is there any other way?

Convert string value to type and pass as type parameter.



In the below code... i am getting all filenames from a directory.  parsing out the directory names & the .vb extension. . . then converting those filesnames to classes.  Every file in the LPCriteria direcotry is its own class with a "Evaluate" function.

The problem comes in here:

Dim boolFlagged As Boolean = CType(MyInstance, objType).Evalua

Because the "objType" comes up as "type 'objType' is not defined".   the parameter requested is "Object as Type".  But i dont know the type, as it is really the name of the file...       any ideas how i get this parameter passed in?   Thanks! :)

Dim strPath As String = System.AppDomain.CurrentDomain.BaseDirectory()
Dim files As String() = System.IO.Directory. _
     GetFiles(strPath & "App_Code\GeneralClasses\LPCriteria\", "*")


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?

Error : Cannot convert method group 'ToString' to non-delegate type 'int'.

Ive gotten this error to my underlined line(bold): Cannot convert method group 'ToString' to non-delegate type 'int'. 
How do i Solve it??

 protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)

        Label2.Visible = true;
        SqlConnection conn = new SqlConnection("Data Source= EN12-2-20-PC02\\SQLEXPRESS;" + "Initial Catalog=ssms;Integrated Security=SSPI");

        DataSet ds = null;
        ds = new DataSet();
        int timestamp = 0;
        timestamp = GridView1.SelectedDataKey.Value.ToString;

        SqlDataAdapter da = null;
        string mySQL = null;
        mySQL = "SELECT timestamp from loginHistory where username = '" + lblShowUser.Text + "'";
        da = new SqlDataAdapter(mySQL, conn);
        da.Fill(ds, "loginHistory");
        DataSet dsSel = new DataSet();

        GridView1.DataSource = dsSel;

TreeSelector : playing with generics and type inference

create a generic way to define a selection starting from a tree of objects, the most simpler way as possible.

Let's start with the beginning...
Here is a very simple little interface defining a node of the tree, basically, a value and the references to the child nodes.

UnTyped DataSets and Strongly Type DataSets

We all are use datasets as a means of carrier of data from one layer to another. Most of the time we are using weakly typed datasets. In this article I will explain the differences between weakly typed datasets and strongly type datasets
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