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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
SqlConnection vCon = new SqlConnection("Server = your_server_name; Database = your_database_name; User ID=sa; Password=yourpassword");
// password bhgui bol - Data Source=your_database_name;Initial Catalog=test;Integrated Security=True
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SqlCommand vCommand = new SqlCommand("SELECT * FROM sys_user", vCon);
SqlDataAdapter vAdapter = new SqlDataAdapter(vCommand);
DataSet vDataset = new DataSet();
vAdapter.Fill(vDataset);
dataGridView1.DataSource = vDataset.Tables[0];
}
private void button1_Click(object sender, EventArgs e)
{
SqlCommand vCommand2 = new SqlCommand("INSERT INTO sys_user(username,userpass,type,actiondate) VALUES('moojig','password','client',GETDATE())",vCon);
vCommand2.ExecuteNonQuery();
vCommand2.Dispose();
}
}
}
No comments:
Post a Comment