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
Can we do database operations without using any of the ado.net objects?
Explain the difference between data reader and data set?
How to create dynamic gridview?
Can datareader hold data from multiple tables?
What are the data providers in ADO.NET framework?
Which is faster dataset or datareader?
What is the difference between SqlCommand and SqlCommandBuilder?
What is the purpose of using adodb?
Which is better entity framework or ado.net?
Explain why edit is not possible in repeater?
Define partial class?
What is the default Timeout for SqlCommand.CommandTimeout property?
What is ole access?
Explain the advantages and disadvantages of using datalist?
What is ado data control?