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 8257017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:03:52+00:00 2026-06-08T02:03:52+00:00

I have the following code in wpf with vb.net and sql CE 3.5, and

  • 0

I have the following code in wpf with vb.net and sql CE 3.5, and my OS is win7 64bit. Visual studios is 2010. I imported the following:

Imports System.ComponentModel
Imports System.Data.SqlServerCe
Imports System.Data

The main part of the code is:

            Dim Con As SqlCeConnection = New SqlCeConnection(DataSource)
            Dim Cmd As SqlCeCommand
            If Con.State = ConnectionState.Closed Then Con.Open()

            'Inserting Prime Details
            Try
                Cmd = New SqlCeCommand("INSERT INTO [ContactPrime]([ID],[Namee],[Company],[JobTitle],[Number],[Address],[Typee] VALUES (@ID,@Namee,@Company,@JobTitle,@Number,@Address,@Typee)", Con)
                With InsertObject.Prime
                    Cmd.Parameters.Add(New SqlCeParameter("@ID", SqlDbType.NVarChar)).Value = .ID
                    Cmd.Parameters.Add(New SqlCeParameter("@Namee", SqlDbType.NVarChar)).Value = .Namee
                    Cmd.Parameters.Add(New SqlCeParameter("@Company", SqlDbType.NVarChar)).Value = .Company
                    Cmd.Parameters.Add(New SqlCeParameter("@JobTitle", SqlDbType.NVarChar)).Value = .JobTitle
                    Cmd.Parameters.Add(New SqlCeParameter("@Number", SqlDbType.NVarChar)).Value = .Number
                    Cmd.Parameters.Add(New SqlCeParameter("@Address", SqlDbType.NVarChar)).Value = .Address
                    Cmd.Parameters.Add(New SqlCeParameter("@Typee", SqlDbType.NVarChar)).Value = .Typee
                End With
                Cmd.ExecuteNonQuery()
            Catch ex As Exception

            End Try


            'Inserting  Numbers of Contact
            Try
                For Each num In InsertObject.Numbers
                    Cmd = New SqlCeCommand("INSERT INTO [ContactNumbers]([ContactID],[ID],[Title],[Mobile],[Land],[Fax],[Email],[IsPrimary] VALUES (@ContactID,@ID,@Title,@Mobile,@Land,@Fax,@Email,@IsPrimary)", Con)
                    With num
                        Cmd.Parameters.Add(New SqlCeParameter("@ContactID", SqlDbType.NVarChar)).Value = .ContactID
                        Cmd.Parameters.Add(New SqlCeParameter("@ID", SqlDbType.NVarChar)).Value = .ID
                        Cmd.Parameters.Add(New SqlCeParameter("@Title", SqlDbType.NVarChar)).Value = .Title
                        Cmd.Parameters.Add(New SqlCeParameter("@Mobile", SqlDbType.NVarChar)).Value = .Mobile
                        Cmd.Parameters.Add(New SqlCeParameter("@Land", SqlDbType.NVarChar)).Value = .Land
                        Cmd.Parameters.Add(New SqlCeParameter("@Fax", SqlDbType.NVarChar)).Value = .Fax
                        Cmd.Parameters.Add(New SqlCeParameter("@Email", SqlDbType.NVarChar)).Value = .Email
                        Cmd.Parameters.Add(New SqlCeParameter("@IsPrimary", SqlDbType.Bit)).Value = .IsPrimary
                    End With
                    Cmd.ExecuteNonQuery()
                Next
            Catch ex As Exception

            End Try

The error I get is:

A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll

Could you please tell me where I have done wrong. The connection works perfectly, I test with a select statement and it worked, it seems my insert statement is wrong.

Thank you in advance.

  • 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-08T02:03:53+00:00Added an answer on June 8, 2026 at 2:03 am

    It seems, you are not closing the bracket before VALUES starts…

    "INSERT INTO [ContactNumbers]([ContactID],[ID],[Title],[Mobile],[Land],
     [Fax],[Email],[IsPrimary] 
     VALUES (@ContactID,@ID,@Title,@Mobile,@Land,@Fax,@Email,@IsPrimary)
    

    You are missing the closing bracket in above statement so corrected query will be like this:

    "INSERT INTO [ContactNumbers]([ContactID],[ID],[Title],[Mobile],[Land],
     [Fax],[Email],[IsPrimary])
     VALUES (@ContactID,@ID,@Title,@Mobile,@Land,@Fax,@Email,@IsPrimary)
    

    Similary, same thing happens in second INSERT query too….

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

Sidebar

Related Questions

I have the following code in a WPF application using Reactive Extensions for .NET:
I have a WPF 4/VB.net 2010 project, and I'm trying to do a visual
I have the following code that adds a background worker into a VB.net WPF
I have the following code for a slider control in WPF: occuranceTimeSlider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;
I am trying my hands on WPF MVVM. I have written following code in
I am NEW to WPF. I have the following XAML code: </Window> ... <Canvas>
I have following code that I am compiling in a .NET 4.0 project namespace
I have the following code in my WPF application: Task task = Task.Factory.StartNew(() =>
I have the following WPF code and it gives me an exception at TextBox
I have a DLL with the following code using System.Text; using Microsoft.Win32; using System.Diagnostics;

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.