It Says I Cannot implicitly convert type System.Data.SqlClient.SqlDataReader
to System.Data.SqlClient.SqlDataAdapter
:
Asked
Active
Viewed 1,432 times
-3
-
3Please edit your question and copy/paste your code as text, according to the rules of StackOverflow. – Rui Jarimba Jul 22 '18 at 10:37
3 Answers
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 :)