The parameterized query '(@UserID nvarchar(4000))SELECT * FROM [JB_DB].[dbo].[Tble_SD_Use' expects the parameter '@UserID', which was not supplied.
public void OnGet() { String ID = Request.Query["UserID"]; try { String connectionString = "Data Source=SQLTableSource"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); String sql = "SELECT * FROM [JB_DB].[dbo].[Tble_SD_Users] WHERE UserID = @UserID;"; using (SqlCommand commmand = new SqlCommand(sql, connection)) { commmand.Parameters.AddWithValue("@UserID", ID); //commmand.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = Convert.ToInt32(id); //commmand.Parameters.AddWithValue("UserID", userInfo.UserID ?? (object)DBNull.Value); //commmand.Parameters.AddWithValue("@UserID", System.Data.SqlDbType.NVarChar).Value = userInfo.UserID; using (SqlDataReader reader = commmand.ExecuteReader()) { if (reader.Read()) { userInfo.ID = "" + reader.GetInt32(0); userInfo.UserID = reader.GetString(1); userInfo.firstName = reader.GetString(2); userInfo.lastName = reader.GetString(3); userInfo.userDepartment = reader.GetString(4); } } } } }
public void OnGet() { String ID = Request.Query["tStatus"]; try { String connectionString = "Data Source=SQLTableSource"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); //String sql = "SELECT TOP (1000) ISNULL([tNumber], ' ') [tNumber], ISNULL([tStatus], ' ') [tStatus], ISNULL([tApplication], ' ') [tApplication], ISNULL([tType], ' ') [tType], ISNULL([tDateLogged], ' ') [tDateLogged], ISNULL ([tDateUpdated], ' ') [tDateUpdated], ISNULL ([tDateClosed],' ') [tDateClosed], ISNULL([tDateLastChecked], ' ') [tDateLastChecked], ISNULL([tUserLogged], ' ') [tUserLogged], ISNULL([tCurrentlyWith], ' ') [tCurrentlyWith], ISNULL([tLoggedOrAdHocTTL], ' ') [tLoggedOrAdHocTTL] FROM [JB_DB].[dbo].[Tble_COF_IT_UK_Tickets];"; String sql = "SELECT * FROM [JB_DB].[dbo].[Tble_COF_IT_UK_Tickets] WHERE tStatus = @tStatus;"; using (SqlCommand command = new SqlCommand(sql, connection)) { command.Parameters.AddWithValue("@tStatus", ID); //command.Parameters.Add("@ID", System.Data.SqlDbType.Int).Value = Convert.ToInt32(ID); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { ticketInfo.ID = "" + reader.GetInt32(0); ticketInfo.tNumber = reader.GetString(1); ticketInfo.tStatus = reader.GetString(2); ticketInfo.tApplication = reader.GetString(3); ticketInfo.tType = reader.GetString(4); ticketInfo.tDateLogged = reader.GetString(5); ticketInfo.tDateUpdated = reader.GetString(6); ticketInfo.tDateClosed = reader.GetString(7); ticketInfo.tDateLastChecked = reader.GetString(8); ticketInfo.tUserLogged = reader.GetString(9); ticketInfo.tCurrentlyWith = reader.GetString(10); ticketInfo.tLoggedOrAdHocTTL = reader.GetString(11); } } } } }
Request.Query["ID"]
ID
Quote:ID didn't appear to have a value.
string id="Request.Query["tStatus"]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)