-3

It Says I Cannot implicitly convert type System.Data.SqlClient.SqlDataReader to System.Data.SqlClient.SqlDataAdapter:

It Says I Cannot implicitly convert type System.data.sqlclient.sqldatareader to system.data.sqlclient.sqldatadapter

nvoigt
  • 75,013
  • 26
  • 93
  • 142
stxy
  • 13
  • 4

3 Answers3

0

Your compiler is correct.

Replace the lines with:

con.Open();

var adapter = new SqlDataAdapter(cmd);

itms.Load(adapter);
nvoigt
  • 75,013
  • 26
  • 93
  • 142
0

You actually meant to use a SqlDataReader rather like

SqlDataReader reader = cmd.ExecuteReader();
Rahul
  • 76,197
  • 13
  • 71
  • 125
0

You can use something like this:

            var connstr = db.Database.Connection.ConnectionString;
            SqlConnection connection;
            connection = new SqlConnection(connstr);
            connection.Open();
            SqlDataAdapter adapter = null;
            DataTable tab = new DataTable();

            adapter = new SqlDataAdapter("select Query from [Drag-Drop] where [User_ID] = '" + UserID + "' order by Clock desc", connection);
            adapter.Fill(tab);
            string DQuery = tab.Rows[0][0].ToString();

Let me know, if helps :)