TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anvar S
NA
12
1.3k
grid view and stored procedure
Aug 9 2018 5:39 AM
hai this is all i done using stored procedure insert,update and delete.i also select a gridview in visual studio form.Now i want to display the inserted datas on the grid view using stored procedure.
what would be the likely code for it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace WebApplication31
{
public partial class insertion : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=REDEEMER3\\REDEEMER;Initial Catalog=Test;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("new",con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id",0);
cmd.Parameters.AddWithValue("@name", txtname.Text);
cmd.Parameters.AddWithValue("@email", txtemail.Text);
cmd.Parameters.AddWithValue("@address", txtaddress.Text);
cmd.Parameters.AddWithValue("@password", txtpwd.Text);
cmd.Parameters.AddWithValue("@query", 1);
cmd.ExecuteNonQuery();
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("new", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("query", 2);
cmd.Parameters.AddWithValue("id", 0);
cmd.Parameters.AddWithValue("name", txtname.Text);
cmd.Parameters.AddWithValue("@email", txtemail.Text);
cmd.Parameters.AddWithValue("@address", txtaddress.Text);
cmd.Parameters.AddWithValue("@password", txtpwd.Text);
cmd.ExecuteNonQuery();
}
protected void Button3_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("new", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@query", "3");
cmd.Parameters.AddWithValue("@id", txtid.Text);
cmd.Parameters.AddWithValue("@name", 0);
cmd.Parameters.AddWithValue("@email", 0);
cmd.Parameters.AddWithValue("@address", 0);
cmd.Parameters.AddWithValue("@password", 0);
cmd.ExecuteNonQuery();
}
}
}
Reply
Answers (
1
)
Remove users who do not belong to groups using CSOM.
How to create in VC++ database program in MFC application ?