برای مشاهده مفیدترین ارسال در این موضوع اینجا کلیک کنید

نمایش نتایج: از شماره 1 تا 2 از مجموع 2
  1. #1
    مدیر بازنشسته
    تاریخ عضویت
    2011 June
    محل سکونت
    گرگان
    ارسال ها
    1,170
    تشکر
    62
    تشکر شده 1,587 بار در 809 پست
    نوشته های وبلاگ
    49


    1 امتياز مثبت از 1 راي
    آيا اين پست براي شما سودمند بود؟ بله | خیر
    فکر کنم تیتر کامل باشه

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.SqlClient;

    namespace sandogh
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void btnInsert_Click(object sender, EventArgs e)
    {
    try
    {
    SqlConnection ObjConnect = new SqlConnection("Data Source=ST72;Initial Catalog=sandogh;Integrated Security=True");
    SqlCommand ObjCommand = new SqlCommand();
    string Str = string.Format("Insert InTo Tbl_sandogh(Fname,Lname,Mablagh,Shomare)values('{0}','{1}',{2},{3})", txtInsertFname.Text, txtInsertLname.Text, txtInsertMablagh.Text, txtInsertShomare.Text);
    ObjCommand.Connection = ObjConnect;
    ObjCommand.CommandText = Str;
    ObjConnect.Open();
    ObjCommand.ExecuteNonQuery();
    ObjConnect.Close();
    MessageBox.Show("Insert InTO ...");
    txtInsertFname.Text = "";
    txtInsertLname.Text = "";
    txtInsertMablagh.Text = "";
    txtInsertShomare.Text = "";
    }
    catch (SqlException ecp)
    {
    MessageBox.Show(ecp.Message);
    }

    }

    private void btnDelete_Click(object sender, EventArgs e)
    {
    try
    {
    SqlConnection ObjConnect = new SqlConnection("Data Source=ST72;Initial Catalog=sandogh;Integrated Security=True");
    SqlCommand ObjCommand = new SqlCommand();
    string Str = string.Format("Delete From Tbl_sandogh Where Shomare={0}", txtDeleteShomare.Text);
    ObjCommand.CommandText = Str;
    ObjCommand.Connection = ObjConnect;
    ObjConnect.Open();
    ObjCommand.ExecuteNonQuery();
    ObjConnect.Close();
    MessageBox.Show("Delete From ...");
    txtDeleteShomare.Text = "";
    }
    catch (SqlException ecp)
    {
    MessageBox.Show(ecp.Message);
    }
    }

    private void btnShow_Click(object sender, EventArgs e)
    {
    SqlConnection ObjConnect = new SqlConnection("Data Source=ST72;Initial Catalog=sandogh;Integrated Security=True");
    SqlCommand ObjCommand = new SqlCommand();
    string Str = string.Format("Select * From Tbl_sandogh");
    SqlDataAdapter Kamun = new SqlDataAdapter();
    DataTable Siloo = new DataTable();

    ObjCommand.Connection = ObjConnect;
    ObjCommand.CommandText = Str;
    Kamun.SelectCommand = ObjCommand;

    ObjConnect.Open();
    ObjCommand.ExecuteNonQuery();
    Kamun.Fill(Siloo);
    ObjConnect.Close();

    dataGridView_Show.Show(Siloo);
    dataGridView_Show.Update();

    }
    }
    }


    پروژه رو براتون در پایین گذاشتم:
    ProjectSandogh

    سوالی بود ،بفرمایین
    بااحترام

    ===============================================

    اینم مثل بالاییه منتها یک سری چیزای دیگه اضافه داره ، خیلی میتونه کمک کنه
    امیدوارم مفید فایده باشه
    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 ST
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    SqlConnection ObjConnect = new SqlConnection("Data Source=RASTIN-PC;Initial Catalog=Student;Integrated Security=True");
    SqlCommand ObjCommand = new SqlCommand();
    string str = string.Format("Insert InTo Tbl_Student (Fname,Lname,Idname) Values ('{0}','{1}',{2})", textBox1.Text, textBox2.Text, textBox3.Text);
    ObjCommand.CommandText = str;
    ObjCommand.Connection = ObjConnect;
    ObjConnect.Open();
    ObjCommand.ExecuteNonQuery();
    ObjConnect.Close();
    MessageBox.Show("OK");
    textBox1.Text = "";
    textBox2.Text = "";
    textBox3.Text = "";
    }
    catch (SqlException ecp)
    {
    MessageBox.Show(ecp.Message);
    }
    }

    private void btn_Delete_Click(object sender, EventArgs e)
    {
    try
    {
    SqlConnection ObjConnect = new SqlConnection("Data Source=RASTIN-PC;Initial Catalog=Student;Integrated Security=True");
    SqlCommand ObjCommand = new SqlCommand();
    string str = string.Format("Delete From Tbl_Student Where Idname={0}", textBox3.Text);
    ObjCommand.CommandText = str;
    ObjCommand.Connection = ObjConnect;
    ObjConnect.Open();
    ObjCommand.ExecuteNonQuery();
    ObjConnect.Close();
    MessageBox.Show("OK");
    textBox1.Text = "";
    textBox2.Text = "";
    textBox3.Text = "";
    }
    catch(SqlException ecp)
    {
    MessageBox.Show(ecp.Message);
    }
    }

    private void btn_Update_Click(object sender, EventArgs e)
    {
    try
    {
    SqlConnection ObjConnect = new SqlConnection("Data Source=RASTIN-PC;Initial Catalog=Student;Integrated Security=True");
    SqlCommand ObjCommand = new SqlCommand();
    SqlDataAdapter Kamun = new SqlDataAdapter();
    DataTable Siloo = new DataTable();
    string str = string.Format("Update Tbl_Student Set Fname,Lname Where Idname = {0}",textBox3.Text);

    ObjCommand.CommandText = str;
    ObjCommand.Connection = ObjConnect;
    Kamun.SelectCommand = ObjCommand;


    ObjConnect.Open();
    ObjCommand.ExecuteNonQuery();
    Kamun.Fill(Siloo);
    ObjConnect.Close();

    dataGridView1.Show();
    dataGridView1.Update();
    MessageBox.Show("OK");
    textBox1.Text = "";
    textBox2.Text = "";
    textBox3.Text = "";
    }
    catch(SqlException ecp)
    {
    MessageBox.Show(ecp.Message);
    }
    }

    private void btn_Select_Click(object sender, EventArgs e)
    {
    try
    {
    SqlConnection ObjConnect = new SqlConnection("Data Source=RASTIN-PC;Initial Catalog=Student;Integrated Security=True");
    SqlCommand ObjCommand = new SqlCommand();
    SqlDataAdapter Kamun = new SqlDataAdapter();
    DataTable Siloo = new DataTable();
    string str = string.Format("Select * From Tbl_Student");

    ObjCommand.CommandText = str;
    ObjCommand.Connection = ObjConnect;
    Kamun.SelectCommand = ObjCommand;


    ObjConnect.Open();
    ObjCommand.ExecuteNonQuery();
    Kamun.Fill(Siloo);
    ObjConnect.Close();

    dataGridView1.Show();
    dataGridView1.Update();
    //MessageBox.Show("OK");
    //textBox1.Text = "";
    //textBox2.Text = "";
    //textBox3.Text = "";
    }
    catch (SqlException ecp)
    {
    MessageBox.Show(ecp.Message);
    }
    }

    }
    }


    موفق باشین
    بااحترام

    موضوعات مشابه:
    ویرایش توسط NIIT : 5th November 2011 در ساعت 10:44 PM
    آرامش محصول تفکر نیست! آرامش هنر نیندیشیدن به انبوه مسائلیست که ارزش فکر کردن ندارد...

 

 

کاربران برچسب خورده در این موضوع

کلمات کلیدی این موضوع

علاقه مندی ها (Bookmarks)

علاقه مندی ها (Bookmarks)

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  


Powered by vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0
Persian Language By Ustmb.ir
این انجمن کاملا مستقل بوده و هیچ ارتباطی با دانشگاه علوم و فنون مازندران و مسئولان آن ندارد..این انجمن و تمامی محتوای تولید شده در آن توسط دانشجویان فعلی و فارغ التحصیل ادوار گذشته این دانشگاه برای استفاده دانشجویان جدید این دانشگاه و جامعه دانشگاهی کشور فراهم شده است.لطفا برای اطلاعات بیشتر در رابطه با ماهیت انجمن با مدیریت انجمن ارتباط برقرار کنید
ساعت 02:46 PM بر حسب GMT +4 می باشد.