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.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\users\codem\documents\visual studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf;Integrated Security=True");
SqlCommand cmd;
con.Open();
cmd = new SqlCommand("select * from kkkk", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
foreach(DataRow dr in dt.Rows)
{
int i =Convert.ToInt32(txtrow.Text) ;
if(dt.Rows[i]!=null)
{
label1.Text = dt.Rows[i]["name1"].ToString();
label2.Text = dt.Rows[i]["name2"].ToString();
}
break;
}
cmd.ExecuteNonQuery();
con.Close();
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
}
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.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\users\codem\documents\visual studio 2012\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Database1.mdf;Integrated Security=True");
SqlCommand cmd;
con.Open();
cmd = new SqlCommand("select * from kkkk", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
foreach(DataRow dr in dt.Rows)
{
int i =Convert.ToInt32(txtrow.Text) ;
if(dt.Rows[i]!=null)
{
label1.Text = dt.Rows[i]["name1"].ToString();
label2.Text = dt.Rows[i]["name2"].ToString();
}
break;
}
cmd.ExecuteNonQuery();
con.Close();
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
}
No comments:
Post a Comment