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
How will you fill the gridview by using datatable object at runtime?
Explain the namespaces in which .net has the data functionality class.
Explain the two fundamental objects in ado.net?
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?
How can we serialize the dataset object?
What are the Features of a dataset
How to aggregating data across related tables?
Explain the difference in an abstract class and an interface?
Explain advantages of ado.net?
How can we add relation between tables in a dataset?
What are the namespaces used in ADO.Net to connect to a database?
Define different execute methods of ADO.NET command object ?
Does entity framework use ado.net?
Is entity framework better than ado.net?
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?