Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:10:06+00:00 2026-05-31T22:10:06+00:00

I have an ms-access database called db.mdb and it contains various table. I;m creating

  • 0

I have an ms-access database called db.mdb and it contains various table. I;m creating a Account Creation page with ASP.NET and VB.NET.

I’m trying to input fields within the page into ms-acess db but when I open the db there are no values entered despite web develop not showing any errors.

Can you kindly help me?

This is the code:

Imports System.Data
Imports System.Data.OleDb
Imports System.Data.Odbc



Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub TextBox1_TextChanged(sender As Object, e As System.EventArgs) Handles txtName.TextChanged

    End Sub

    Protected Sub btnCreateAccount_Click(sender As Object, e As System.EventArgs) Handles btnCreateAccount.Click

        Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Brian\Documents\Visual Studio 2010\WebSites\WebSite3\db.mdb;User Id=admin;Password=;")

        Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO [USER] (UserName, UserSurname, Address, Country, TelNo, UserLogin, UserPassword, UserTypeID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", conn)




        If txtPass.Text = txtCPass.Text Then

            conn.Open()


            cmd.Parameters.Add("@UserName", OleDbType.VarChar, 255).Value = txtName.Text
            cmd.Parameters.Add("@UserSurname", OleDbType.VarChar, 255).Value = txtSurname.Text
            cmd.Parameters.Add("@Address", OleDbType.VarChar, 255).Value = txtUsername.Text
            cmd.Parameters.Add("@Country", OleDbType.VarChar, 255).Value = txtCountry.Text
            cmd.Parameters.Add("@TelNo", OleDbType.Integer).Value = txtTelNo.Text
            cmd.Parameters.Add("@UserLogin", OleDbType.VarChar, 255).Value = txtUsername.Text
            cmd.Parameters.Add("@UserPassword", OleDbType.VarChar, 255).Value = txtPass.Text
            cmd.Parameters.Add("@UserTypeID", OleDbType.VarChar, 255).Value = "U"





            cmd.ExecuteNonQuery()

            conn.Close()
            lblAccount.Visible = True



        End If

    End Sub
End Class

EDIT:

So I’m trying to autonumber the UserID field. It’s set as auto number from the access database. Whenever I try to input the details into the page from the page, it won’t allow me, giving me an error that the AutoNumber field cannot be NULL. So I added the piece of code :

newID = Int32.Parse(cmd2.ExecuteScalar()) + 1

So that I get the maximum number from that column in the table and increment it by 1 and then added with the other command.

cmd.Parameters.Add("@UserID", OleDbType.VarChar, 255).Value = newID

However its giving me an error saying

Conversion from type 'DBNull' to type 'String' is not valid.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:10:07+00:00Added an answer on May 31, 2026 at 10:10 pm

    You haven’t open the connection before calling cmd2.ExecuteScalar() function. And first parameter is wrong. Should be @UserID instead of @Address.

    conn.Open()
    newID = Int32.Parse(cmd2.ExecuteScalar()) + 1
    'Not sure what is column type (Varchar or Int)
    cmd.Parameters.Add("@UserID", OleDbType.Integer, 2).Value = newID
    ...
    cmd.ExecuteNonQuery()
    conn.Close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.Net page using ADO to query MS access database and as
I have a table called Recharge in a Access Database. Some of the fields
I have a table set up on a mysql database called access with three
I have an Access database in which I drop the table and then create
I have a Microsoft Access database query that I'm trying to import into a
I have an Access database I am querying with SQL from VB .NET. The
I have database called wisherDB, and I have a table called tbltasks inside the
In ms-access database i have a table named tableA this table has a column
We have an MS Access 2007 database with a simple form displaying table data.
If you have, for example, a database table called Person (ID,Name etc) what kind

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.