This one has stumped me. I debug the following code (which is ran during Protected Sub CreateUserWizard1_CreatedUser) and I check the values of all my parameters...there are NO spaces. I put the DEBUG point right at the executenonquery statement. THEN, I quit debugging before the redirect and go to the DB and there are a bunch of spaces added to several columns.
Why?
(NOTE...it seems to always be roleStr & CouncilPosStr that it does it with--I even tried making the insertString without the parameters--coding the variables into the string..same thing)
(Also--here is the string copied DIRECTLY from Debug:
"INSERT INTO [members] (fname, lname, email, home_phone, cell_phone, address, city, state, zip, userName, role, password, councilPosition) VALUES ('Rob', 'Searing', '
[email protected]', 'none', 'none', '1234 Some St', 'City', 'KS', '66213', 'rjsearing', 'No Role', 'password', 'none')"
)
Dim insertString = "INSERT INTO [members] (fname, lname, email, home_phone, cell_phone, address, city, state, zip, userName, role, password, councilPosition) VALUES (@fname, @lname, @email, @home, @cell, @address, @city, @state, @zip, @userNa, @rol, @pass, @councilPosStr)"
Dim knightsDBConn As New SqlConnection(conString)
Dim sqlCmd As New SqlCommand(insertString, knightsDBConn)
sqlCmd.CommandType = CommandType.Text
sqlCmd.Parameters.AddWithValue("@fname", firstNameStr)
sqlCmd.Parameters.AddWithValue("@lname", lastNameStr)
sqlCmd.Parameters.AddWithValue("@email", emailStr)
sqlCmd.Parameters.AddWithValue("@home", phoneStr)
sqlCmd.Parameters.AddWithValue("@cell", cellStr)
sqlCmd.Parameters.AddWithValue("@address", addressStr)
sqlCmd.Parameters.AddWithValue("@city", cityStr)
sqlCmd.Parameters.AddWithValue("@state", stateStr)
sqlCmd.Parameters.AddWithValue("@zip", zipStr)
sqlCmd.Parameters.AddWithValue("@userNa", userNameStr)
sqlCmd.Parameters.AddWithValue("@rol", "roleStr")
sqlCmd.Parameters.AddWithValue("@pass", passwd)
sqlCmd.Parameters.AddWithValue("@councilPosStr", councilPosStr)
knightsDBConn.Open()
sqlCmd.ExecuteNonQuery()
sqlCmd = Nothing
Response.Redirect("~/admin/addmember.aspx")