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

How will you fill the gridview by using datatable object at runtime?

1058


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

1092


Explain the two fundamental objects in ado.net?

992


I loaded the dataset with a table of 10 records. One of the records is deleted from the backend, how do you check whether all the 10 records were present while updating the data(which event and steps) and throw the exception 28 can datareader hold data from multiple tables?

1023


How can we serialize the dataset object?

1003


What are the Features of a dataset

1311


How to aggregating data across related tables?

1045


Explain the difference in an abstract class and an interface?

927


Explain advantages of ado.net?

1052


How can we add relation between tables in a dataset?

1000


What are the namespaces used in ADO.Net to connect to a database?

1216


Define different execute methods of ADO.NET command object ?

1101


Does entity framework use ado.net?

989


Is entity framework better than ado.net?

1018


How can I retrieve two tables of data at a time by using data reader? Data reader read and forward only, how is it possible to get 2 tables of data at a time?

983