Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

i want 2 pass values(enterd in textbox)to table in sql
server without using stored procedure in c#.plz tell me
code with an example.

Answer Posted / bala

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}

private void button1_Click(object sender, EventArgs
e)
{
String ConnectionString = "Data
Source=ServerName;Initial Catalog=DatabaseName;Integrated
Security=true";
String Query = "insert into tablename values('"
+ textBox1.Text + "')";
SqlConnection Con = new SqlConnection
(ConnectionString) ;
Con.Open();
SqlCommand Cmd = new SqlCommand(Query, Con);
Cmd.ExecuteNonQuery();
Cmd.Dispose();
Con.Close();

}
}
}

Is This Answer Correct ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages using ado.net?

1027


What are the advantages of using datalist?

998


How to Read, Add, Update and Delete record in Entity Framework ?

1030


What is the difference between connected and disconnected environment?

1097


What is ole in excel?

931


What is linq and entity framework?

995


Which database is the ado.net sql connection object designed for?

1030


differance between ADO vs ADO.Net?

1051


Explain the namespaces in which .net has the data functionality class.

1070


Is ado.net an orm?

952


How do you connect to sql server database without using sqlclient?

1095


What are all the different methods under sqlcommand?

976


What is the use of Dataview?

1121


How can you add or remove rows from the datatable object of dataset?

1017


What are the difference between readonly vs. Const?

1002