Select Values From Local Database Connection.
Retrive Values From Local Database (.sdf)(Database connection) To Display DatagridView in Window Application Smart Device 2008 C#.
DEMO
Coding
First - Add Database Connection - Add - Add Reference - System.Data.SqlCeConnection.
Next - Inserted Table Values - Display DataGridView
Next - Design Add - Button & DataGridview
Next - Add Namespace - Get Connection String - Retrive to Bind GridView
Retrive Values From Local Database (.sdf)(Database connection) To Display DatagridView in Window Application Smart Device 2008 C#.
DEMO
Coding
using System;
using
System.Linq;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
System.Data.SqlServerCe;
namespace
SmartDeviceProject1
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void Form1_Load(object
sender, EventArgs e)
{
}
private
void button1_Click_1(object
sender, EventArgs e)
{
SqlCeConnection
con = new SqlCeConnection
("Data
Source=" +(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase))
+ "\\AppDatabase1.sdf;Persist Security
Info=False");
con.Open();
SqlCeCommand
cmd = new SqlCeCommand("select name from reg",con);
SqlCeDataAdapter
adp = new SqlCeDataAdapter(cmd);
DataTable
dt = new DataTable();
adp.Fill(dt);
dataGrid1.DataSource = dt;
}
}
}
First - Add Database Connection - Add - Add Reference - System.Data.SqlCeConnection.
Next - Inserted Table Values - Display DataGridView
Next - Design Add - Button & DataGridview
Next - Add Namespace - Get Connection String - Retrive to Bind GridView
0 comments:
Post a Comment