This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//data Display example | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Data.SqlClient; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
namespace killercodes_in.DataDisplay | |
{ | |
public partial class Form1 : Form | |
{ | |
public string _connStr_ = "Data Source=127.0.0.1,1433;Initial Catalog=killercodes;User Id=sa;Password=iamadmin;"; | |
public Form1() | |
{ | |
InitializeComponent(); | |
BindingManagerBase _BM; | |
} | |
private void _bConnection_Click(object sender, EventArgs e) | |
{ | |
try | |
{ | |
SqlConnection _sqCon = new SqlConnection(); | |
_sqCon.ConnectionString = _connStr_; | |
_sqCon.Open(); | |
_sqCon.Close(); | |
MessageBox.Show("Conn Sucess :)"); | |
} | |
catch (Exception ExSq) | |
{ | |
MessageBox.Show(ExSq.Message); | |
} | |
} | |
private void _RunQuery(string myQuery) | |
{ | |
try | |
{ | |
SqlCommand _SqlCmd = new SqlCommand(); | |
_SqlCmd.Connection = new SqlConnection(_connStr_); | |
_SqlCmd.Connection.Open(); | |
_SqlCmd.CommandText = myQuery; | |
_SqlCmd.ExecuteNonQuery(); | |
_SqlCmd.Connection.Close(); | |
} | |
catch (Exception ExSq) | |
{ | |
MessageBox.Show(ExSq.Message); | |
} | |
} | |
private void _tExeQuery_Click(object sender, EventArgs e) | |
{ | |
_RunQuery(textBox1.Text); | |
} | |
private void _bDataRdr_Click(object sender, EventArgs e) | |
{ | |
SqlCommand _SqlCmd = new SqlCommand(); | |
_SqlCmd.Connection = new SqlConnection(_connStr_); | |
_SqlCmd.Connection.Open(); | |
_SqlCmd.CommandText = "Select * from grademstr"; | |
SqlDataReader _dr = _SqlCmd.ExecuteReader(); | |
while (_dr.Read()) | |
{ | |
textBox2.Text = _dr.GetValue(0).ToString(); | |
textBox3.Text = _dr.GetValue(1).ToString(); | |
} | |
_dr.Close(); | |
_SqlCmd.Connection.Close(); | |
} | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
DataSet myd = new DataSet(); | |
} | |
} | |
} |