Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Feature Forums
  3. - Uncategorised posts -
  4. MAKING PROGRAMING CODE BY GAUTAM RANA

MAKING PROGRAMING CODE BY GAUTAM RANA

Scheduled Pinned Locked Moved - Uncategorised posts -
csharpsharepointlinqgraphicssecurity
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member_14180671
    wrote on last edited by
    #1

    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 TestProgram { public partial class StudentDetails : Form { SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=F:\TestProgram\TestProgram\Student.mdf;Integrated Security=True;User Instance=True"); public StudentDetails() { InitializeComponent(); } protected void OpenConnection() { if (con.State == System.Data.ConnectionState.Open) { con.Close(); } con.Open(); } protected void CloseConnection() { con.Close(); } protected void Clear() { txtname.Text = ""; txtaddress.Text = ""; txtcourse.Text = ""; txtaddress.Text = ""; // btndelete.Enabled = false; } protected void bindGrid() { try { SqlCommand cmd = new SqlCommand("select * from Student_Detail", con); OpenConnection(); SqlDataReader dr = cmd.ExecuteReader(); dataGridView1.Rows.Clear(); while (dr.Read() == true) { dataGridView1.Rows.Add(dr[0], dr[1], dr[2], dr[3]); } CloseConnection(); } catch (Exception err) { MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnsave_Click(object sender, EventArgs e) { try { if (txtname.Text == "") { MessageBox.Show("Please enter details ", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtname.Focus(); return; } SqlCommand cmd = new SqlCommand("SP_Insert", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter parm = new SqlParameter("@Student_Name", SqlDbType.VarChar); parm.Value = txtname.Text; parm.Direction = ParameterDirection.Input; cmd.Parameters.Add(parm); parm = new SqlParameter("@Student_Course", SqlDbType.VarChar); parm.Value = txtcourse.Text; parm.Direction = ParameterDirection.Input; cmd.Parameters.Add(parm); parm = new SqlParameter("@Student_Address", SqlDbType.VarChar); parm.Value = txtaddress.Text; parm.Direction = ParameterDirection.Input; cmd.Parameters.Add(parm); OpenConnection(); cmd.ExecuteNonQuery(); MessageBox.Show("Data Save Successfully"); Clear(); bindGrid(); CloseConnection(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } private void btnupdate_Click(object sender, EventArgs e) { try { int id; id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); SqlCommand cmd = new SqlCommand("SP_Update", con); cmd.C

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups