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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:30:44+00:00 2026-05-26T19:30:44+00:00

I have a problem storing my inserted data to my database. When I’m using

  • 0

I have a problem storing my inserted data to my database. When I’m using mdf file that created within of visual studio it won’t work. When I’m using dbo file that created from SQL Server 2008 it when I tried to store my inserted data to database it worked well.

I’m using a stored procedure. There was no error occurred. help me pls.

here is the code using sqlcommand:

 SqlConnection myConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\FifthColumn.mdf; Integrated Security=True; User Instance=True");
 myConn.Open();
 SqlCommand mycommand = myConn.CreateCommand();
 mycommand.CommandText = "InsertIncident";
 mycommand.CommandType = CommandType.StoredProcedure;
 mycommand.Parameters.Add("@Country", SqlDbType.NChar, 2, "Country").Value = inputCountry;
 mycommand.Parameters.Add("@IncidentTypeID", SqlDbType.NChar, 2, "Country").Value = inputIncidentTypedID;
 mycommand.Parameters.Add("@AgentID", SqlDbType.NChar, 2, "Country").Value = inputAgentID;
 mycommand.Parameters.Add("@incidentDate", SqlDbType.SmallDateTime).Value = inputID;
 mycommand.ExecuteNonQuery();
 myConn.Close();

here is the code using dataadapter:

 SqlConnection myConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\FifthColumn.mdf; Integrated Security=True; User Instance=True");
 SqlDataAdapter myDA = new SqlDataAdapter();
 myConn.Open();
 myDA.InsertCommand = myConn.CreateCommand();
 myDA.InsertCommand.CommandText = "InsertIncident";
 myDA.InsertCommand.CommandType = CommandType.StoredProcedure;
 myDA.InsertCommand.Parameters.Add("@Country", SqlDbType.NChar, 2, "Country").Value = inputCountry;
 myDA.InsertCommand.Parameters.Add("@IncidentTypeID", SqlDbType.NChar, 2, "Country").Value = inputIncidentTypedID;
 myDA.InsertCommand.Parameters.Add("@AgentID", SqlDbType.NChar, 2, "Country").Value = inputAgentID;
 myConn.Close();
  • 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-26T19:30:44+00:00Added an answer on May 26, 2026 at 7:30 pm

    Data adapter automatically opens and closes the connection. if you use data adapter, it is unnecessary to open or close the connection.

    Second, data adapter is mostly used to fetch the block data from database into a dataset by using fill method of data adapter.

    You can use insert command or update command property of data adapter to insert or update any data. They must be assigned to a command object before use.

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

Sidebar

Related Questions

I have a big text file containing data that needs to be extracted and
The problem is that only some of the XML data is being Inserted into
I am using LaTeX and I have a problem concerning string manipulation. I want
I have a problem that output string must be utf8-formatted, I am writing currently
I have a problem converting a string binary to a decimal I was using
I have a problem with Lucene's scoring function that I can't figure out. So
I have got an application, that is getting data via XML-files. During the parsing-part
I have a problem with JPA I will explain in detail: I created a
In PHP, I want to insert into a database using data contained in a
What is a good data structure for storing phone numbers in database fields? I'm

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.