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

  • SEARCH
  • Home
  • 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 8564237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:09:05+00:00 2026-06-11T17:09:05+00:00

I keep getting error on my WinForms application whenever I create new database and

  • 0

I keep getting error on my WinForms application whenever I create new database and insert data.

This is how I create the database

Public Function CreateDatabase() As String
    Dim ds As String = "Data Source=" + (My.Computer.FileSystem.SpecialDirectories.MyDocuments) + "\" + (Application.ProductName) + "\" + (DBName) + ".wv" + ";Persist Security Info=True;"
    Dim Conn As New SqlCeConnection(ds)
    Dim Cmd1 As New SqlCeCommand()
    Dim Cmd2 As New SqlCeCommand()
    Dim SqlCeDB As New SqlCeEngine(ds)
    Dim Msg As String
    Try
        If Not System.IO.File.Exists(DBName) Then
            Msg = "Database successfully created in " & Application.StartupPath
            SqlCeDB.CreateDatabase()
            Cmd1.Connection = Conn
            Conn.Open()
            'Create acPassword Table
            Cmd1.CommandText = "CREATE TABLE [wvAccount](" & _
                                "[acName] [nvarchar](100) NOT NULL, " & _
                                "[acPassword] [nvarchar](100) NOT NULL," & _
                                "[acKeyFile] [nvarchar](64) NULL, " & _
                                "[acLastLogin] [nvarchar](100) NULL, " & _
                                "[acLastModified] [nvarchar](100) NULL)"
            Cmd1.ExecuteNonQuery()
            'Create pmPassword Table
            Cmd2.Connection = Conn
            Cmd2.CommandText = "CREATE TABLE [wvPassword](" & _
                                "[pmID] [int] CONSTRAINT pmID PRIMARY KEY NOT NULL, " & _
                                "[pmCat] [nvarchar](100) NOT NULL, " & _
                                "[pmTitle] [nvarchar](100) NOT NULL," & _
                                "[pmUsername] [nvarchar](100) NOT NULL," & _
                                "[pmSiteURL] [nvarchar](100) NULL," & _
                                "[pmNotes] [nvarchar](300) NULL)"
            Cmd2.ExecuteNonQuery()
        Else
            Msg = "There is already a Database with that name."
        End If
    Catch ex As Exception
        Msg = ex.Message
    End Try
    Return Msg
End Function

And this is how I insert the data right after I create the database and populate with table

Private Sub ADD_PA()
    Dim StrSQL_vault As String = "INSERT INTO [wvAccount] ([acName], [acPassword], [acKeyFile], [acLastLogin], [acLastModified]) VALUES (@acName, @acPassword, @acKeyFile, @acLastLogin, @acLastModified)"
    classlibrary_vault = New ConnectionLibrary_Vault
    classlibrary_vault.openConnection_vault(strconnection_vault)
    If Not classlibrary_vault.isConnectionOpen_vault() Then
        Exit Sub
    End If
    classlibrary_vault.initializeCommand_vault(StrSQL_vault)
    classlibrary_vault.addParameter_vault("@acName", SqlDbType.NVarChar, txtName.TextLength, txtName.Text)
    classlibrary_vault.addParameter_vault("@acPassword", SqlDbType.NVarChar, txtEncryptedCode.TextLength, txtEncryptedCode.Text)
    classlibrary_vault.addParameter_vault("@acKeyFile", SqlDbType.NVarChar, txtKeyFile.TextLength, txtKeyFile.Text)
    classlibrary_vault.addParameter_vault("@acLastLogin", SqlDbType.NVarChar, txtLastLogin.TextLength, txtLastLogin.Text)
    classlibrary_vault.addParameter_vault("@acLastModified", SqlDbType.NVarChar, txtLastModified.TextLength, txtLastModified.Text)
    Try
        objcommand_vault.ExecuteNonQuery()
        txtAccountName.Text = txtName.Text
        'Set controls
        _Main.NotifyIcon.Visible = True
        _Main.NotifyIcon.ShowBalloonTip(1, Application.ProductName, VAULT_CREATED, ToolTipIcon.Info)
        Me.ParentForm.Controls.Remove(Me)
        controlManagePasswords()
    Catch ex As Exception
        DevComponents.DotNetBar.MessageBoxEx.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Try
End Sub

At first when I had a primary key on my wvAccount table, I experienced no problem but now I keep getting

Database cannot be null, the empty string, or string of only
whitespace.

I have no problem creating the database, the only thing bothers me is when I try to insert a data on wvAccount. Btw, I’m using SQL Server CE 4.0 and VB.Net

The .wv extension allows me to read and write on my database previously, so probably, there’s no problem with that.

  • 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-06-11T17:09:06+00:00Added an answer on June 11, 2026 at 5:09 pm

    Solved it myself. I forgot to initiate the same connection string I used to create the database, instead I used the connection string for different database. Dumb me. I really have to sleep now.

    Dim ds As String = "Data Source=" + (My.Computer.FileSystem.SpecialDirectories.MyDocuments) + "\" + (Application.ProductName) + "\" + (DBName) + ".wv" + ";Persist Security Info=True;"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error with my Play 2.0 application: play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[MatchError:
I want to insert a word (public) inside parenthesis with sed keep getting error
I am trying to make this query work but i keep getting error. insert
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep getting an error saying that @android:style/Widget.Holo.Light.Button.Borderless is not public and so can't
I keep getting this error and have no idea why. I googled and scanned
I keep getting this error on emulator: I copied this from a tutorial and
I keep getting this error Error in readPNG(destfile) : libpng error: PLTE: CRC error
I keep getting this error when I try and run this script. It has
I keep getting this error when I try and view my register user page

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.