0% found this document useful (0 votes)
114 views18 pages

Genshin Error Code 9114 Solutions

Your ultimate guide! Explore this section for best practices and valuable resources to maximize your experience and get the most out of this initiative.

Uploaded by

princemadhubhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views18 pages

Genshin Error Code 9114 Solutions

Your ultimate guide! Explore this section for best practices and valuable resources to maximize your experience and get the most out of this initiative.

Uploaded by

princemadhubhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CSE307:-ASP.

NET Core Programming 22CS038 – Prince Raiyani

Practical - 8
Aim: Implement Registration, Login, Logout & change password features using [Link] and
[Link] (LINQ), (Use Dataset, Data Reader, XML Reader & Data Sources (SQL, Object &
XML) with Any Windows or Web Application).

Code:
CREATE TABLE [dbo].[Users] (
[UserID] INT IDENTITY (1, 1) NOT NULL,
[UserName] NVARCHAR (50) NOT NULL,
[Password] NVARCHAR (50) NOT NULL,
[Email] NVARCHAR (50) NOT NULL
);

Registration Form:
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
public partial class _Default : [Link]
{
protected void RegisterButton_Click(object sender, EventArgs e)
{
string connectionString =
[Link]["Users"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connectionString))
{
string query = "INSERT INTO Users (Username, Password, Email) VALUES
(@Username, @Password, @Email)"
SqlCommand cmd = new SqlCommand(query, conn);

Page 1 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
[Link]("@Username", [Link]);
[Link]("@Password", [Link]);
[Link]("@Email", [Link]);
try
{
[Link]();
int rowsAffected = [Link]();

if (rowsAffected > 0)
{
[Link] = "Registration successful!";
}
else
{
[Link] = "Registration failed.";
}
}
catch (Exception ex)
{
[Link] = "Error: " + [Link];
}
}
}

[Link]
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="[Link]" Inherits="[Link]" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>

Page 2 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
<form id="form1" runat="server">
<div>
<h2>Login</h2>
<asp:Label ID="lblMessage" runat="server"
ForeColor="Red"></asp:Label><br /><br />
Username: <asp:TextBox ID="txtUsername"
runat="server"></asp:TextBox><br /><br />
Password: <asp:TextBox ID="txtPassword" TextMode="Password"
runat="server"></asp:TextBox><br /><br />
<asp:Button ID="btnLogin" Text="Login" runat="server"
OnClick="btnLogin_Click" /><br /><br />
<asp:HyperLink ID="hlRegister" runat="server"
NavigateUrl="~/[Link]">New User? Register Here</asp:HyperLink><br
/><br />
<asp:HyperLink ID="hlChangePassword" runat="server"
NavigateUrl="~/[Link]">Forgot Password? Change
Password</asp:HyperLink>
</div>
</form>
</body>
</html>

[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Practical8

Page 3 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
{
public partial class login : [Link]
{
protected void btnLogin_Click(object sender, EventArgs e)
{
string username = [Link];
string password = [Link];
string connString =
[Link]["adoConnectionString"].Connectio
nString;
using (SqlConnection conn = new SqlConnection(connString))
string query = "SELECT UserID FROM Users WHERE Username =
@Username AND Password = @Password";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Username", username);
[Link]("@Password", password);
[Link]();
SqlDataReader reader = [Link]();
if ([Link])
{
[Link]();
Session["UserID"] = reader["UserID"];
[Link]("[Link]
}
else
{
[Link] = "Invalid username or password.";
}
[Link]();
}
}
}

Page 4 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Practical8
{
public partial class home : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] == null)
{
[Link]("[Link]");
}
}
protected void btnLogout_Click(object sender, EventArgs e)
{
[Link]();
[Link]("[Link]");
}
}
}

[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

Page 5 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
using [Link];
using [Link];
{
public partial class register : [Link]
{
protected void btnRegister_Click(object sender, EventArgs e)
{
string username = [Link];
string email = [Link];
string password = [Link];
string connString =
[Link]["adoConnectionString"].Conne
ctionString;
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "INSERT INTO Users (Username, Email, Password)
VALUES (@Username, @Email, @Password)";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Username", username);
[Link]("@Email", email);
[Link]("@Password", password);
[Link]();
int result = [Link]();
[Link]();
if (result > 0)
{
[Link] = "Registration successful!";
}
else
{
[Link] = "Registration failed.";
}

Page 6 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
}
}
}

[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Practical8
{
public partial class changepassword : [Link]
{
protected void btnChangePassword_Click(object sender, EventArgs e)
{
string username = [Link];
string oldPassword = [Link];
string newPassword = [Link];
string connString =
[Link]["adoConnectionString"].Conne
ctionString;
using (SqlConnection conn = new SqlConnection(connString))
{
// Step 1: Validate username and old password
string validateQuery = "SELECT Password FROM Users WHERE
Username = @Username";
SqlCommand validateCmd = new SqlCommand(validateQuery,
conn);
[Link]("@Username", username);

Page 7 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
[Link]();
SqlDataReader reader = [Link]();
if ([Link]())
{
string storedPassword = reader["Password"].ToString();
// Check if the old password matches
if (storedPassword != oldPassword)
{
[Link] = "Old password is incorrect.";
[Link]();
return;
}
}
else
{
[Link] = "Username not found.";
[Link]();
return;
}
[Link]();
string updateQuery = "UPDATE Users SET Password =
@NewPassword WHERE Username = @Username";
SqlCommand updateCmd = new SqlCommand(updateQuery, conn);
[Link]("@NewPassword",
newPassword);
[Link]("@Username", username);
[Link]();
int result = [Link]();
[Link]();
if (result > 0)
{
[Link] = "Password changed successfully!";

Page 8 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
}
else
{
[Link] = "Failed to change password.";
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
// No need to check if the user is logged in since we're asking for
username and old password
}
}
}
Output:

Page 9 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani

Page 10 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani

Practical - 9
Aim: Display User List and provide search/filter / update / delete facility (Use Data Controls
like Data List, Grid View, Detail View, Repeater, and List Bound Control)
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="[Link]"
Inherits="Default3" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<h1>
Admin DashBoard</h1>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="UserID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowSelectButton="True" />
<asp:BoundField DataField="UserID" HeaderText="UserID" InsertVisible="False"
ReadOnly="True" SortExpression="UserID" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:BoundField DataField="Password" HeaderText="Password"
SortExpression="Password" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email"
/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:Users %>" DeleteCommand="DELETE FROM [Users] WHERE [UserID] =
@UserID" InsertCommand="INSERT INTO [Users] ([UserName], [Password], [Email])
VALUES (@UserName, @Password, @Email)" SelectCommand="SELECT * FROM [Users]"

Page 11 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
UpdateCommand="UPDATE [Users] SET [UserName] = @UserName, [Password] =
@Password, [Email] = @Email WHERE [UserID] = @UserID">
<DeleteParameters>
<asp:Parameter Name="UserID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="Email" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="UserID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</form>
</body>
</html>

[Link]
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="[Link]" Inherits="[Link]"%>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>User Management</h2>

Page 12 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
<asp:TextBox ID="txtSearch" runat="server" placeholder="Search by
Username"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search"
OnClick="btnSearch_Click" />
<br /><br />
<asp:GridView ID="gvUsers" runat="server"
AutoGenerateColumns="False" OnRowCommand="gvUsers_RowCommand">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="User ID"
ReadOnly="True" />
<asp:BoundField DataField="Username" HeaderText="Username" />
<asp:BoundField DataField="Email" HeaderText="Email" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnEdit" runat="server" Text="Edit"
CommandName="EditUser" CommandArgument='<%# Eval("UserID") %>' />
<asp:Button ID="btnDelete" runat="server" Text="Delete"
CommandName="DeleteUser" CommandArgument='<%# Eval("UserID") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Label ID="lblMessage" runat="server"
ForeColor="Green"></asp:Label>
</div>
</form>
</body>
</html>

[Link]
using System;
using [Link];
using [Link];
Page 13 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace practical9
{
public partial class UserManagement : [Link]
{
private string connString =
[Link]["adoConnectionString"].Conne
ctionString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadUsers();
}
}
private void LoadUsers(string filter = "")
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "SELECT * FROM Users";
if (![Link](filter))
{
query += " WHERE Username LIKE @Filter";
}
SqlCommand cmd = new SqlCommand(query, conn);
if (![Link](filter))
{
Page 14 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
[Link]("@Filter", "%" + filter + "%");
}
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
string filter = [Link]();
LoadUsers(filter);
}
protected void gvUsers_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if ([Link] == "EditUser")
{
int userId = Convert.ToInt32([Link]);
[Link]($"[Link]?UserID={userId}");
}
else if ([Link] == "DeleteUser")
{
int userId = Convert.ToInt32([Link]);
DeleteUser(userId);
LoadUsers();
}
}
private void DeleteUser(int userId)
{
using (SqlConnection conn = new SqlConnection(connString))
Page 15 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
{
string query = "DELETE FROM Users WHERE UserID =
@UserID";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@UserID", userId);
[Link]();
[Link]();
[Link]();
[Link] = "User deleted successfully!";
}
}
}
}

[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace practical9
{
public partial class EditUser : [Link]
{
private string connString =
[Link]["adoConnectionString"].Connectio
nString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
Page 16 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
{
int userId = Convert.ToInt32([Link]["UserID"]);
LoadUser(userId);
}
}
private void LoadUser(int userId)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "SELECT * FROM Users WHERE UserID = @UserID";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@UserID", userId);
[Link]();
SqlDataReader reader = [Link]();
if ([Link]())
{
[Link] = reader["Username"].ToString();
[Link] = reader["Email"].ToString();
}
[Link]();
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
int userId = Convert.ToInt32([Link]["UserID"]);
UpdateUser(userId);
}
private void UpdateUser(int userId)
{
using (SqlConnection conn = new SqlConnection(connString))
{
string query = "UPDATE Users SET Username = @Username, Email =
Page 17 of 18
CSE307:-[Link] Core Programming 22CS038 – Prince Raiyani
@Email WHERE UserID = @UserID";
SqlCommand cmd = new SqlCommand(query, conn);
[Link]("@Username",
[Link]());
[Link]("@Email", [Link]());
[Link]("@UserID", userId);
[Link]();
[Link]();
[Link]();
[Link] = "User updated successfully!";
}
}
}
}

Output:

Page 18 of 18

You might also like