convert type 'System.Data.DataSet' to 'System.Data.DataTable'

 I got this error  : Cannot implicitly convert type 'System.Data.DataSet' to 'System.Data.DataTable'

i have written code like this

DataTable dt = new DataTable();

dt = GetGalleryImages(name);

12/24/2008 12:00:09 PM 91979 articles. 4 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 55
Get it on Google Play
Get it on Apple App Store

Possibly coz GetGalleryImages returns a dataset and not a datatable?


DataSet ds = GetGalleryImages(name);

12/24/2008 12:02:19 PM

what type does GetGalleryImages return?  If this returns a dataset then you will have to change datatable to dataset, then index the table of the dataset.

Please mark as answer if you find helpful.

Ustes G.
12/24/2008 12:03:05 PM

Similar Artilces:

Cannot implicitly convert type 'System.Data.DataTable' to 'System.Data.Dataset'
I am using an excel spreadsheet as a data source to build a dataset which is then used to populate a grid:  I am getting the following error: Cannot implicitly convert type 'System.Data.DataTable' to 'System.Data.Dataset' Here's my code:private DataSet GetData(String description, String mpnumber, String link) { //MPData will represents the Data in Application Cache. We will use Cache Data //for performance purposes, because MP Information will not change often. I choose // to also use Dataset Filtering instead of SQL Server Filtering. However the DataAccess layer should // remain parameterized to allow others to filter the data in the database.DataSet MPData; //Get Cache if (Cache["MPData"] != null) {MPData = (DataSet)Cache["MPData"]; } else { //Get Data From Data Access and Cache try { //Get Data MPData = VFileDataGetter.GetMPData(description, mpnumber);   //Recreate the Item in Cache and hold for 30 minutes. Consider Adding to config fileCache.Insert("MPData", MPData, null, DateTime.Now.AddMinutes(CACHE_TIME), TimeSpan.Zero);   } catch { //Catch Error and return a Null Datasetreturn null; } } //Return Data Setreturn MPData; } Here is my code from DataAccess.cs: public class VFileData {public DataTable GetMPData(string searchMPNbr, string searchDescription) { // Create connection string variable.string sConnectionString = HttpContext.Current.Server.MapPath(@"~\Ap...

Error: foreach statement cannot operate on variables of type 'System.Data.DataSet' because 'System.Data.DataSet' does not contain a definition for 'GetEnumerator', or it is inaccessible
I am getting error on this line DataSet dsdata=new DataSet(); SQL="Seelct * from tablename"; //dsdata contains result of the above query foreach(DataRow dr in dsdata) //This line gives error Error: foreach statement cannot operate on variables of type 'System.Data.DataSet' because 'System.Data.DataSet' does not contain a definition for 'GetEnumerator', or it is inaccessible DataSet dsdata=new DataSet(); SQL="Select * from tablename"; //dsdata contains result of the above query foreach(DataRow dr in dsdata.Tables[0].Rows) //This line SHOULD NOT NOW give error The message actually explained EXACTLY what the error was. DataSet does not expose this method required to do a foreach. The Rows collection in the DataTable object does. Starting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog...

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.DataBind() 7 GVCRlisting.PageIndex = pageIndex 8 End Sub  My HomePage -"It is more blessed to give than to receive." Acts 20: 35 (NIV, Bible)Progress - "Never discourage anyone...who continually makes progress, no matter how slow." Plato I doubt this is the right way to do it, unless you have already bound the data earlier. What you need to do is to Re-populate your DataSource, and get the DataTable which you can then pass to the SortDataTable method. The GridView.DataSource property should not be used to retrieve the current data after a post (if at all possible?). GVCRlisting.DataSource = SortDataTable(GetMyDataTable(), False) GVCRlisting.DataBind() GVCRlisting.PageIndex = pageIndex  If this post was useful to you, please mark it as answer. Thank you! ngaisteve1:5 GVCRlisting.DataSource = Sor...

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 that helps! Marcie    http://www.datagridgirl.comNEW! DataTable myTable; DataView MyView; DataSet ds = new DataSet();  // Bind dataGridView to DataView. MyView = (DataView)dataGridView1.DataSource;  // Bind  DataView to Table. myTable = (DataTable)MyView.Table; After this code you can add this table to dataset , I think this will help for You  ...

convert type 'System.Xml.XmlDataDocument' to 'System.Data.DataSet'
I am using XMLDataDocument in web services which returns XMLDataDocument using this XMLDataDocument for Dataset in application getting error Cannot implicitly convert type 'System.Xml.XmlDataDocument' to 'System.Data.DataSet'  any idea  XmlDataDocument has DataSet property to get the document as a data set.Thanks,Teemu KeiskiFinland, EU  [WebMethod]    public XMLDataDocument xmldoc(DateTime x, DateTime y)    {        df = dateFrom;        dt = dateTo;   &...

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

Linq Error Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<AnonymousType#1>' to 'System.Data.EnumerableRowCollection<System.Data.DataRow>'.
Hi I am using a AdventureWorks database and trying to use LINQ to query the data. i am not able to get the AsDataView() if i don't declare query as EnumerableRowCollection. But if i declare the query EnumerableRowCollection it shows me an error Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Data.EnumerableRowCollection'. AdventureWorks.AdventureWorksDataContext db = new AdventureWorks.AdventureWorksDataContext(); EnumerableRowCollection query = from t in db.TransactionHistories.AsEnumerable() select new { t.TransactionID }; As i am having this code in separate class i would like to return DataView instead of ToList(). Any hlep. Thanks If you change your projection to be the entire DataRow, you should be able to call AsDataView.  LinqDataView is only supported for identiy projection (select t) and not as you do t.TransactionID(which generates an anonymous type) Hey, When you do select new { t.TransactionID }, this creates IEnumerable<{type}>, where {type} is the transactionID data type.  You would have to stop at dbo.TransactionHistories.AsEnumerable() to get the effect that you want.  See if the DataView can take a constructor where you can pass an enumerable type into it...Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart'...

Cannot convert type 'myWebService.GetMyMethode' to 'System.Data.DataSet'
Hi all, I have a webservice that I call in my other application web. In my webservice, I have a method that return a DataSet. MyWebService new1 = new MyWebService();GridView1.DataSource = (DataSet)new1.GetMyMethod();GridView1.DataBind();  But I had this message : Cannot convert type 'myWebService.GetMyMethode' to 'System.Data.DataSet' I found the KB article number 815131 But this bug to apply  only to :   • Microsoft Visual C# .NET 2003 Standard Edition • Microsoft Visual C# .NET 2002 St...

Cannot implicitly convert type 'System.Data.DataTable' to 'TEntities'.
hi this i am getting: Error 2 Cannot implicitly convert type 'System.Data.DataTable' to 'TEntities'. An explicit conversion exists (are you missing a cast?) public class LookUpTables<TEntities> where TEntities : DataTable, new() { private SqlConnection con;private static LookUpTables<TEntities> instance;public static LookUpTables<TEntities> Instance { get { // Use 'Lazy initialization' if (instance == null) {instance = new LookUpTables<TEntities>(); }return instance; } } // Note: Constructor is 'private'...

Value of type 'System.Data.Dataset' cannot be converted to 'String'
I receive the above error for line 57 which is: Address.text = Clientinfo(DropDownlist1.Items(DropDownList1.SelectedIndex).text) I'm trying to take the selected item from the dropdownlist1 and have the data from the query 'Clientinfo' appear using the label control called 'address'. I plan to format it to be used as a mailing address: 123 Street City, State Zip Etc. Obviously I am learning as I go. Can anyone give me an alternative or find my error. Much appreciated. The code is below: Sub Page_Load(Sender As Object, E As EventArgs) If Not Page.IsPostBack Then DropDownList1.DataTextField = "ClientsFullName" DropDownList1.DataSource = ClientDropDown() DropDownlist1.Databind() End If End Sub Function ClientDropDown() As System.Data.DataSet Dim connectionString As String = "server='(local)'; trusted_connection=true; database='porman'" Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "SELECT [Clients].[ClientsFullName] FROM [Clients]" Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter dataAdapter.SelectCommand = dbCommand Dim dataSet ...

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

Error : Value of type 'System.Data.DataTable' cannot be converted to 'String'
Hi, I have a compilation error : Value of type 'System.Data.DataTable' cannot be converted to 'String'. I want to erase all the records in my Access database and update it with a DataTable. My code lines : Dim conn As OleDbConnection Dim da As OleDbDataAdapter Dim ds As DataSet Dim sql As String sql = "SELECT * FROM menu;" conn = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=d:\www\tgc\prof_tech\fsthilaire\parametres_site\parametres_site.mdb" ) da = New OleDbDataAdapter(sql, conn) conn.Open() ds = New DataS...

Error: Value of type 'System.Data.CommandBehavior' cannot be converted to 'System.IAsyncResult'.
  I wrote this code to retrieve data from the database using autocomplete extender control. Dim Dr As SqlDataReaderDim RtData As List(Of String) = New List(Of String) Dr = MysqlCmd.EndExecuteReader(Data.CommandBehavior.CloseConnection) While Dr.Read()RtData.Add(Dr("CustName").ToString()) End While   Plz Help!   regards   yamani     The EndExecuteReader does not take a CommandBehavior.  The BeginExecuteReader does.  Please follow the example on the MSDN documentation:

Error type 'System.Data.DataTable' to type 'PRODUCT_LISTDataTable'
I can't figure this one out. I created new solution in vs2005 from using vs2003 and I have a problem I can't find an answer to. I get the following error that relates to passing a to a dataset.datatable named "ProductList.PRODUCT_LISTDataTable".  It says it can't cast the object from one type to the other, and I've tried "CType" and doesn't work. Error: Unable to cast object of type 'System.Data.DataTable' to type 'PRODUCT_LISTDataTable'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trac...

c:\inetpub\wwwroot\WebApplication1\subject_info.aspx.vb(658): Value of type '1-dimensional array of System.Data.DataRow' cannot be converted to 'System.Data.DataRow'.
Hi everyone, I have a "select link" in one of the fields in the DataGrid. I want it retreive informations when i click on that link and display in the text box so i can modify data. The problem is i always have this error when i COMPILE: " Value of type '1-dimensional array of System.Data.DataRow' cannot be converted to 'System.Data.DataRow' ". Here's is my code: ************************************************ Private Sub UpdateDetails(ByVal uSubjectID As String) DaLecturer1 = Session("ds") Dim dt As DataTable = DaLectur...

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

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"];  Response.Write("<br>Initial is: "  + _initial + "<br />ViewState is " + ViewState["TermIndex"]);  if (_initial == (string) ViewState["TermIndex"])  return Color.Red; return Color.Blue;} private void BindTerm(object term){    //create a connection to the db    OleDbConnection oCxn = dbConnectDataDictionary();  ViewState["TermIndex"] = term; SetButtonBackColor(term); Response.Write("<br>term in BindTerm is: " + term); Response.Write("<br>ViewState in BindTerm is: " + ViewState["TermIndex"]);// FillGlossary(ref oCxn, TermsQuery, ref GlossaryRepeater, term);  //Data set Two  DataSet _data3 = new DataSet();  string _Query = "SELECT[attribute name] AS TermIndex, [attribute type], [source for raw data], definition FROM [Attributes] WHERE [Attribute Name] like ...

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

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) =...

Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView'
Trying to create an alternateview to send a txt email with the html formatted email.  I've used string builder to create the whole email, but I get this error.  Any ideas why?  i've bolded the line that throws the error... Dim EmailBodyTxt As New StringBuilder EmailBodyTxt.Append("<html><style type='text/css'>.table{border:solid; border-color:#006666; width:600;} ")EmailBodyTxt.Append("<body><table class='table'><tr><td colspan='2'><h1>Test<br />RESPONSE SYSTEM</h1></td>...

Value of type 'Integer' cannot be converted to 'System.Data.SqlClient.SqlDataReader'
Value of type 'Integer' cannot be converted to 'System.Data.SqlClient.SqlDataReader' I get the above error when I try to do this code: Dim dr As SqlDataReaderDim ID As Integer dr = oDeveloper.GetDeveloper(CllrID) anyone any ideas around this? macca   well obviously, GetDeveloper Takes a DataReader What do you mean Jeffrey? How can I get the values from GetDeveloper to my datareader dr then? macca Enable Strict for your project.  That will tell you exactly what's wrong. I think the error message already says what is wrong.If you haven't got a clue about something don...

error --------------------unable to cast object of type''to type[]
getting error in the bold line  so plz help me to resolve the problem  Private Sub form1_load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load con.Open() Strquery = "Select * from optimizer" adp = New SqlDataAdapter(Strquery, con) adp.Fill(ds, "optimizer") dtb = ds.Tables("optimizer") 'cmdCommand = New SqlCommand(Strquery, con) Try 'dr = cmdCommand.ExecuteReader fs = File.Open("c:/abc.txt", FileMode.Create, FileAccess.Write, FileShare.None) sw = New StreamWriter(fs) For Each drow In ds.Tables sw.WriteLine(drow(0).ToString +...

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:...

Web resources about - convert type 'System.Data.DataSet' to 'System.Data.DataTable' -

Resources last updated: 3/3/2016 8:56:35 AM