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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:34:16+00:00 2026-05-30T09:34:16+00:00

My table name is Customer . It has four columns CustomerId CustomerName CustomerAddress PhoneNo

  • 0

My table name is Customer. It has four columns

CustomerId
CustomerName
CustomerAddress
PhoneNo

This is my c# code. I am not getting any exceptions and data is not inserting into database.

string connString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\VictoryDatabase.mdf;Integrated Security=True;User Instance=True";
SqlConnection myConnection = new SqlConnection(connString);

try
{
   myConnection.Open();
   string query = "insert into Customer(CustomerName,CustomerAddress,PhoneNo) values (@CustNm,'@CustAdd',@Ph)";
   SqlCommand myCommand = new SqlCommand(query,myConnection);
   myCommand.Parameters.AddWithValue("CustNm",Print[0].CustomerName);
   myCommand.Parameters.AddWithValue("CustAdd",Print[0].Address);
   myCommand.Parameters.AddWithValue("Ph",Print[0].Telephone);

   Console.WriteLine(Print[0].Telephone);

   myCommand.ExecuteNonQuery();
   myConnection.Close();
}
catch (Exception e)
{
   Console.WriteLine(e.ToString());
}
  • 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-30T09:34:18+00:00Added an answer on May 30, 2026 at 9:34 am

    As I’ve said before on this site – the whole User Instance and AttachDbFileName= approach is flawed – at best! Visual Studio will be copying around the .mdf file and most likely, your INSERT works just fine – but you’re just looking at the wrong .mdf file in the end!

    If you want to stick with this approach, then try putting a breakpoint on the myConnection.Close() call – and then inspect the .mdf file with SQL Server Mgmt Studio Express – I’m almost certain your data is there.

    The real solution in my opinion would be to

    1. install SQL Server Express (and you’ve already done that anyway)

    2. install SQL Server Management Studio Express

    3. create your database in SSMS Express, give it a logical name (e.g. VictoryDatabase)

    4. connect to it using its logical database name (given when you create it on the server) – and don’t mess around with physical database files and user instances. In that case, your connection string would be something like:

      Data Source=.\\SQLEXPRESS;Database=VictoryDatabase;Integrated Security=True
      

      and everything else is exactly the same as before…

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

Sidebar

Related Questions

This is an extract of the JPA entities schema @Entity @Table(name=customer) public class Customer
Good afternoon I have a table that has customer id, name, computer, laptop, blah,
I have a table called customer which has, among others, a column called name
Let's say my SQL database contains a table called 'Customer'. This Customer has an
i have data like this. Table customer | customerId | fullName | sex |
Lets say i have a table with the following data Customer table: Name amount
I have a customer table where I'm currently storing: Last Name First Name Middle
Is table name prefix for fields to be update not allowed in SQL ?
I have a table name that starts with an underscore does that give any
I have a table name Discount that has the following schema: PK DiscountID int

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.