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 you will deal result set? How do you sort a dataset?If a dataset contains 100 rows, how to fetch rows between 5 and 15 only?
How can we serialize the dataset object?
How do you update a dataset in ado.net and how do you update database through dataset?
What you mean by filtering of data?
If we are not returning any records from the database, which method is to be used?
What is dataset object? Explain the various objects in dataset.
What are the advantages of oledb compared with other classes?
What is the use of Dataview?
Explain About ado.net components/objects. Usage of data adapters and tell the steps to retrieve data.
How to pass multiple tables in datasets simultaneously?
What are the advantages of ado.net?
What is difference between executenonquery and executequery?
What is ado.net in mvc?
What is ado.net connection?
How do you update database through dataset?