473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Why won't user's details go into Access db?

Hello

I have a new user register form that requires a username and password with a MS Access db with two fields only, username and password.

The username and password, as a plain text password, successfully go into the db. However, when I attempt to salt/hash the password, it fails. I don't get any errors either in Visual Studio or online, and the form and the form field data simply stay in page - that is, nothing happens.

This is the code I am using (trimmed):

Expand|Select|Wrap|Line Numbers
  1. Imports Microsoft.AspNet.Membership.OpenAuth
  2. Imports System
  3. Imports System.Linq
  4. Imports System.Web
  5. Imports System.Web.UI
  6. Imports System.Data.OleDb
  7. Imports System.Security.Cryptography
  8.  
  9.  
  10. Partial Class register1
  11.  
  12.     Inherits System.Web.UI.Page
  13.  
  14.     Sub New()
  15.         MyBase.New()
  16.  
  17.     End Sub
  18.  
  19. Protected Sub btnReg_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReg.Click
  20.         Try
  21.             Using conn As OleDbConnection = New OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings("students").ConnectionString)
  22.  
  23.                 Dim Sql As String = "INSERT INTO university (username,[password],strEmail) VALUES (@username,@password,@strEmail)"
  24.  
  25.                 Dim cmd As New OleDbCommand(Sql, conn)
  26.  
  27.                 conn.Open()
  28.  
  29.                 cmd.Parameters.AddWithValue("@username", username.Text)
  30.                 cmd.Parameters.AddWithValue("@password", password.Text)
  31.                 cmd.Parameters.AddWithValue("@strEmail", strEmail.Text)
  32.  
  33.                 cmd.ExecuteNonQuery()
  34.  
  35.                 conn.Close()
  36.  
  37.             End Using
  38.  
  39.  End Try
  40.  
  41.     End Sub
  42.  
  43.  Public Sub New(password As String)
  44.  
  45.         Dim saltBytes = New Byte(31) {}
  46.         Dim Salt As String = ""
  47.         Dim Hash As String = ""
  48.  
  49.         Using provider = New RNGCryptoServiceProvider()
  50.             provider.GetNonZeroBytes(saltBytes)
  51.         End Using
  52.         Salt = Convert.ToBase64String(saltBytes)
  53.         Hash = ComputeHash(Salt, password)
  54.     End Sub
  55.  
  56.     Private Shared Function ComputeHash(salt As String, password As String) As String
  57.         Dim saltBytes = Convert.FromBase64String(salt)
  58.         Using rfc2898DeriveBytes = New Rfc2898DeriveBytes(password, saltBytes, 1000)
  59.             Return Convert.ToBase64String(rfc2898DeriveBytes.GetBytes(512))
  60.         End Using
  61.     End Function
  62.  
  63.     Public Shared Function Verify(salt As String, hash As String, password As String) As Boolean
  64.         Return hash = ComputeHash(salt, password)
  65.     End Function
  66.  
  67. End Class
I can only see that the word 'password' links these two different sets of code - is that the problem? Or do I need other columns in the db?

Thank you for any help.

Blueie
Mar 12 '16 #1
0 890

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Nico | last post by:
My database have 20 tables and many users. I wish to store encrypted data in 3 tables and have only 3 users have access to them, walking into tables or using forms. Can someone point me a direct...
16
by: Andy_Khosravi | last post by:
I'm in a bit of a pickle. My employer, a health insurance firm, had me design a small database to track benefit issues. The intended users were technical specialists and some managers (about 90...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
7
by: ABC | last post by:
How can I deny all users directly access image files from images folder?
2
by: Jon | last post by:
Hi all, I have an array that has 13 elements each containing data (name, address etc). How would I FIRSTLY place this data in any document/sheet and then SECONDLY email this document to say...
1
by: eduardoben | last post by:
I use a tableadapter with the sql string = select * fom table where field=? I load the desired record in a form and populate textboxes but after i modify them when i use tableadapter.update it...
5
by: Les Desser | last post by:
I know that the .ldb file should show the users currently logged into a database. However, when a user logs out I cannot detect any change in the file. I must be missing something as PSPad...
2
by: muskan | last post by:
hello, I want to give password when we open the enterprise manager .So that only the authorised users can access the database & see the tables . Could u help me for solving this problem. &...
1
by: leela mn | last post by:
Hi Everybody!!! i have a situation where in i should allow users to access the website only once from a particular system.. so is there any way from which we can know all the windows open????
1
by: Sport Girl | last post by:
Hello everybody, i hope that you are doing well. Please can anybody help me with this task, it is urgent: does anybody know how to grant access privileges to tables to users in Access 2007....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.