Back to Blog
Sql convert string to int7/18/2023 For more information about the values this parameter can have, see SQL Format Models. Ok, you starting to create a "mess" here. The functions TODECIMAL, TONUMBER, TONUMERIC, and TODOUBLE accept an optional parameter that specifies the format of the input string, if the input expression evaluates to a string. It works there but do not work in edituser.aspx. I have almost same code (minus dropdown for role) in myaccount.aspx page that is also for editing user's data. How is it then possible that data does not update No error or exception is shown, lblError also does not become visible which means that izmena_korisnika in btnSaveChanges_Click is equal to 0. When I click the button data does not update. Second, it now checks the result, so (for example) if you convert from a string to an int, it can throw an exception if the string contains something that couldn't be converted to an int (e.g., 1234 would succeed, but 123abc would throw). IF EXISTS (SELECT TOP 1 ime FROM Korisnici This is Izmena_Korisnika (Edit user in english) method in WebShop.cs: public int Izmena_Korisnika(string name, string surname, string username, string password, string email, string country, string city, int post_code, string address, int role_id)Ĭomm.CommandType = CommandType.StoredProcedure Ĭomm.CommandText = "dbo.Korisnik_Izmeni" Ĭ(new SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, name)) Ĭ(new SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, surname)) Ĭ(new SqlDbType.NVarChar, 30, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, username)) Ĭ(new SqlDbType.NVarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, password)) Ĭ(new SqlDbType.NVarChar, 50, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, email)) Ĭ(new SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, country)) Ĭ(new SqlDbType.NVarChar, 100, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, city)) Ĭ(new SqlDbType.Int, 5, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, post_code)) Ĭ(new SqlDbType.NVarChar, 255, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, address)) Ĭ(new SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Current, role_id)) Ĭ(new SqlDbType.Int, 4, ParameterDirection.ReturnValue, true, 0, 0, "", DataRowVersion.Current, null)) Īnd this is the SQL Server stored procedure dbo.Korisnik_Izmeni: CREATE PROCEDURE int Int izmena_korisnika = moj_nalog1.Izmena_Korisnika(name, surname, username, password, mail, country, city, postCode, address, user_role) Int postCode = Convert.ToInt32(txtPostCode.Text) When button is clicked it activate this method: protected void btnSaveChanges_Click(object sender, EventArgs e) When edit button is clicked I put mail of a clicked user in Session and redirect to edituser.aspx where I load user's data in textboxes and his role in dropdown. I have list of all users and "edit" and "delete" buttons for each row of a list. I'm currently working on a "edit users" part of control panel. I am making a web store in ASP.NET with a SQL Server database.
0 Comments
Read More
Leave a Reply. |