I am writing a WPF C# application and I want to save fetched row in a variable.
SqlDataAdapter connAdp = new SqlDataAdapter("SELECT * FROM users WHERE (username = '"+uname+"') AND (password = '"+pass+"');",conn);
SqlDataReader fetchInfo = null;
fetchInfo = conn.ExecuteReader();
fetchInfo.Read();
But when I try to build my application it gives error
ExecuteReader not defined
I tried this code also:
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
DataRow row = dt.Rows["username"];
But it gives error too. I am new to C# and WPF, so can anyone tell how I fetch data from SQL Server and store in a variable or array?
I sort it out myself
Here it is guys, i hope it help noobs. You can fetch it with
dr.Read()