0

how to convert from 'string' to 'System.Data.DataTable'
I Have this code and my computer appear kode error
I have put all the web site on the attach
The best overloaded method match for 'System.Data.OleDb.OleDbDataAdapter.Fill(System.Data.DataTable, object)' has some invalid arguments
cannot convert from 'string' to 'System.Data.DataTable'

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

public partial class ContentPage : System.Web.UI.Page
{
    
    public OleDbConnection odc;
    public DataSet ds;
    public OleDbDataAdapter oda;
    public DataTable dt;
    string s;
    protected void Page_Load(object sender, EventArgs e)
    {
        //Label1.Text = "";
        helloUser();
        Label1.Text = s;
        Label2.Text =  DateTime.Now.ToLongDateString();
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Vetura.aspx");
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Response.Redirect("ChangePassword.aspx");
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {


        if (DropDownList1.SelectedItem.ToString()== "Audi")
        {
            Panel15.Visible = true;
            Panel14.Visible = false;
            Panel1.Visible = false;
        }
        else
        {
            if (DropDownList1.SelectedItem.ToString() == "Mercedes")
            {
                Panel14.Visible = true;
                Panel1.Visible = false;
                Panel15.Visible = false;
            }
            else {
                if (DropDownList1.SelectedItem.ToString() == "BMW")
                {
                    Panel1.Visible = true;
                    Panel14.Visible = false;
                    Panel15.Visible = false;

                }
                 }
        }

        
        //ImageButton14.ImageUrl = "D:\\Viti-III Sh.Komp\\RRjeta Komp & Prog WWW\\AutoVetura\\Picture\\zconcept1.jpg";
       /*     OleDbDataReader objReader = null;
        ds = new DataSet();
        string ConnString;
        ConnString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " + ("C:\\AutoBase.mdb");
        odc = new OleDbConnection(ConnString);

        OleDbCommand objComm = new OleDbCommand("ProcN");
        objComm.CommandType = CommandType.StoredProcedure;
        OleDbParameter objParam = new OleDbParameter();
        objParam = objComm.Parameters.Add("@Marka", OleDbType.Char);
        objParam.Direction = ParameterDirection.Input;
        objParam.Value = DropDownList1.SelectedItem.ToString();
        try
        {
            odc.Open();
            objReader = objComm.ExecuteReader();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());

        }
        */
        

    }
    public void helloUser()
    {
        OleDbDataReader objReader = null;
        string ConnString;
        ds = new DataSet();
        //ds1 = new DataSet();
        ConnString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " + ("C:\\db1.mdb");
        odc = new OleDbConnection(ConnString);
        oda = new OleDbDataAdapter(" SELECT Username FROM Tab3", odc);
        oda.Fill("Tab3",ds);
        s = ds.Tables["Tab3"].Rows[0][0].ToString();
    }
    protected void ImageButton14_Click(object sender, ImageClickEventArgs e)
    {
        if (DropDownList2.SelectedItem.ToString() == "Porche")
        {
            Panel16.Visible = true;
            Panel17.Visible = false;
            Panel18.Visible = false;
        }
        else
        {
            if (DropDownList2.SelectedItem.ToString() == "Golf")
            {
                Panel17.Visible = true;
                Panel16.Visible = false;
                Panel18.Visible = false;
            }
            else 
            {
                if (DropDownList2.SelectedItem.ToString() == "BMW")
                {
                    Panel18.Visible = true;
                    Panel17.Visible = false;
                    Panel16.Visible = false;
                }
            }
        }
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        Response.Redirect("Vetura.aspx");
    }
}

Edited by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by rahmet
0

1) Please use code tags!
2) See below.

oda.Fill("Tab3",ds); // <--- wrong order. DataSet first, string second.

Edited by apegram: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.