-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqliCustomDB.cs
More file actions
50 lines (43 loc) · 1.4 KB
/
Copy pathsqliCustomDB.cs
File metadata and controls
50 lines (43 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Data;
using System.Data.SqlClient;
namespace CxAudit_Demo
{
public partial class sqliCustomDB : System.Web.UI.Page
{
static string username = String.Empty;
static int age = -1;
protected void Page_Load(object sender, EventArgs e)
{
try
{
string ID = Request.QueryString[0];
getName(ID);
}
catch { }
}
private void getName(string ID)
{
string username = "No name";
XyzDBSqlConnection conn = new XyzDBSqlConnection("Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=" + Constants.DB_PASSWORD + ";");
XyzDBSqlCommand cmd = new XyzDBSqlCommand();
XyzDBSqlDataReader reader;
cmd.CommandText = "SELECT NAME FROM Users WHERE ID = " + ID;
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
conn.Open();
reader = cmd.XyzDBxecuteMethod();
if (reader.HasRows)
{
username = reader["NAME"].ToString();
age = getAge(username);
}
message.Text = myCustomSanitizer("Welcome " + username);
conn.Close();
}
protected void submit_Click(object sender, EventArgs e)
{
getName(name.Text);
}
}
}