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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:41:54+00:00 2026-06-15T01:41:54+00:00

This is my code for inserting into database from textfields. SqlConnection Connection = new

  • 0

This is my code for inserting into database from textfields.

SqlConnection Connection = new SqlConnection("Data Source=ESHA\\SQLEXPRESS;Initial Catalog=Gen_Lic;User ID=sa;Password=sa@");           

SqlCommand Command = Connection.CreateCommand();

try
{
// Open Connection             
Connection.Open();
////Console.WriteLine("Connection Opened");
// Create INSERT statement with named parameters             
Command.CommandText = "INSERT  INTO Gen_Lic(Lic_No, UserID, Org, UserName, SolType, Version, Lic_Type, Meap_Supp, Lic_From, Lic_To, Supp_From, Supp_To, Max_User, Max_Mach, Mach_IP, Mach_MAC) VALUES (@Lic_No, @UserID, @Org, @UserName, @SolType, @Version, @Lic_Type, @Meap_Supp, @Lic_From, @Lic_To, @Supp_From, @Supp_To, @Max_User, @Max_Mach, @Mach_IP, @Mach_MAC)";
// Add Parameters to Command Parameters collection  

Command.Parameters.AddWithValue("@Lic_No", txtLNo.Text);
Command.Parameters.AddWithValue("@UserID", txtUID.Text);
Command.Parameters.AddWithValue("@Org", txtOrg.Text);
Command.Parameters.AddWithValue("@UserName", txtUName.Text);
Command.Parameters.AddWithValue("@SolType", txtSType.Text);
Command.Parameters.AddWithValue("@Version", txtVer.Text);
Command.Parameters.AddWithValue("@Lic_Type", drpLType.SelectedItem.Text);
Command.Parameters.AddWithValue("@Meap_Supp", rdoMeapSupport.SelectedValue.ToString());
Command.Parameters.AddWithValue("@Lic_From", lblLFrom.Text);
Command.Parameters.AddWithValue("@Lic_To", lblLTo.Text);
Command.Parameters.AddWithValue("@Supp_From", lblSuppFrom.Text);
Command.Parameters.AddWithValue("@Supp_To", lblSuppTo.Text);
Command.Parameters.AddWithValue("@Max_User", txtMaxUsr.Text);
Command.Parameters.AddWithValue("@Max_Mach", txtMaxMach.Text);
Command.Parameters.AddWithValue("@Mach_IP", txtMachIP.Text);
Command.Parameters.AddWithValue("@Mach_MAC", txtMachMac.Text);

Connection.Close();

}

Now the problem is the code is working fine, but the values are not getting inserted into the database. Also, when I apply a breakpoint at the starting of the connection formation, a new blank IE window opens up.

Can someone guide me where am I going wrong?

  • 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-15T01:41:56+00:00Added an answer on June 15, 2026 at 1:41 am

    I think, you are missing the following:

    Command.ExecuteNonQuery(); 
    

    before the Connection.Close()

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

Sidebar

Related Questions

I've recently written a custom API for inserting data into my database from multiple
I have created some form for inserting data into database and for checking if
I have this code here please, which permits me to import data from a
I am using mysql_real_escape_string function while inserting the data into MySQL database. I am
I'm writing application for downloading CSV file from web and inserting data into table
C# code is reading data from database through dynamic queries. Select ID, TransDate from
I'm having trouble inserting data from my registration webform into sqlserver-2008. I'm getting an
I am building an application in which I'm populating data from the database into
I've met an unknown error while inserting data into the database. The LogCat had
I have an extensive form inserting into a SQL database and then from an

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.