When I login I want to display the image of user.
I use Rows[0] but when i change the user that is at row[1] it shows me the row[0] image.
How do i implement a code to switch the rows and know what user is logged on.
I am a beginner here, so take it slow.
`C#
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Username"] != null)
{
String a = ConfigurationManager.ConnectionStrings["MyDatabase"].ConnectionString;
using (SqlConnection con = new SqlConnection(a))
{
DataTable dt = new DataTable();
SqlDataAdapter comanda = new SqlDataAdapter("SELECT *FROM Register", con);
comanda.Fill(dt);
if (dt.Rows.Count > 0)
{
emailutilizator.Text = dt.Rows[0]["Email"].ToString();
}
if (dt.Rows[0]["ImageData"].ToString().Length > 1)
{
Image1.ImageUrl = dt.Rows[0]["ImageData"].ToString();
}
else
{
Image1.ImageUrl = "~/images/defaultuserimg.png";
}
}`
}
The database looks like this
`Tabel
CREATE TABLE [dbo].[Register] (
[Uid] INT IDENTITY (1, 1) NOT NULL,
[Username] NVARCHAR (MAX) NULL,
[Email] NVARCHAR (MAX) NULL,
[Password] NVARCHAR (MAX) NULL,
[ImageData] NVARCHAR (MAX) NULL,
PRIMARY KEY CLUSTERED ([Uid] ASC)
);
`
[The information from database]
[
]2