Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > how to retrieve a column from ms access db and check a radio buttonin c#
 

how to retrieve a column from ms access db and check a radio buttonin c#

how to retrieve a column from ms access db and check a radio buttonin c#
its of YES\NO type in access!!

if in the talbe dat col is checked i wanna check a radio button els another!!!!

d code is incomplete pls help me on this!!!

if (/*dtM.Checked==true ---- wot shud b put here to make this work!*/ )

{

M.Checked =

true;

F.Checked =

false;

}

else

{

M.Checked=

false;

F.Checked =

true;

}

  • Edited byfathatsme Tuesday, August 04, 2009 5:26 AMmore datails
  •  
fathatsme  Tuesday, August 04, 2009 5:21 AM
 

private void button1_Click(object sender, EventArgs e) 

{

OleDbConnection connection = new OleDbConnection(); 
connection.ConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Fahad\Database\Database1.mdb;User Id=admin;"; 

command = new OleDbCommand("SELECT * FROM details", connection); 

OleDbDataAdapter adapter = new OleDbDataAdapter(command); 
 
connection.Open();
DataSet dsSet = new DataSet(); 
adapter.Fill(dsSet);

//use the databinding to show the data in textbox

textBox2.DataBindings.Add(

"Text", dt, "Address", true); 

dateTimePicker1.DataBindings.Add("Text", dt, "DOB", true); 

bool bClmnVal = (bool)dsSet.Tables[0].Rows[0]["YOUR COLUMN NAME"];
 
if (bClmnVal) 
{
   M.Checked = true; 

   F.Checked = false; 

}
else
{
  M.Checked = false; 
  F.Checked = true; 
}

connection.Close();

}

Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.
  • Marked As Answer byfathatsme Tuesday, August 04, 2009 6:51 AM
  • Unmarked As Answer byfathatsme Tuesday, August 04, 2009 6:51 AM
  • Marked As Answer byfathatsme Tuesday, August 04, 2009 6:35 AM
  •  
_SuDhiR_  Tuesday, August 04, 2009 6:34 AM
Get your Data in DataSet

then





bool bClmnVal = (bool)dsSet.Tables[0].Rows[0]["YOUR COLUMN NAME"]; if(bClmnVal) { M.Checked = true; F.Checked =false; } else { M.Checked= false; F.Checked =true; }





Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.

  • Unmarked As Answer byfathatsme Tuesday, August 04, 2009 6:51 AM
  • Marked As Answer byfathatsme Tuesday, August 04, 2009 6:51 AM
  •  
_SuDhiR_  Tuesday, August 04, 2009 6:03 AM

private void button1_Click(object sender, EventArgs e)

{

OleDbConnection connection = new OleDbConnection();

connection.ConnectionString =

@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Fahad\Database\Database1.mdb;User Id=admin;";

command = new OleDbCommand("SELECT * FROM details", connection);

OleDbDataAdapter adapter = new OleDbDataAdapter(command);

DataTable dt = new DataTable();

connection.Open();

adapter.Fill(dt);

DataSet dsSet = new DataSet();

//use the databinding to show the data in textbox

textBox2.DataBindings.Add(

"Text", dt, "Address", true);

dateTimePicker1.DataBindings.Add(

"Text", dt, "DOB", true);

bool bClmnVal = (bool)dsSet.Tables[0].Rows[0]["____"];//err.....cannot find table 0

if (bClmnVal)

{

M.Checked =

true;

F.Checked =

false;

}

else

{

M.Checked =

false;

F.Checked =

true;

}

connection.Close();

}
still not workin!

fathatsme  Tuesday, August 04, 2009 6:22 AM
 

private void button1_Click(object sender, EventArgs e) 

{

OleDbConnection connection = new OleDbConnection(); 
connection.ConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Fahad\Database\Database1.mdb;User Id=admin;"; 

command = new OleDbCommand("SELECT * FROM details", connection); 

OleDbDataAdapter adapter = new OleDbDataAdapter(command); 
 
connection.Open();
DataSet dsSet = new DataSet(); 
adapter.Fill(dsSet);

//use the databinding to show the data in textbox

textBox2.DataBindings.Add(

"Text", dt, "Address", true); 

dateTimePicker1.DataBindings.Add("Text", dt, "DOB", true); 

bool bClmnVal = (bool)dsSet.Tables[0].Rows[0]["YOUR COLUMN NAME"];
 
if (bClmnVal) 
{
   M.Checked = true; 

   F.Checked = false; 

}
else
{
  M.Checked = false; 
  F.Checked = true; 
}

connection.Close();

}

Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.
  • Marked As Answer byfathatsme Tuesday, August 04, 2009 6:51 AM
  • Unmarked As Answer byfathatsme Tuesday, August 04, 2009 6:51 AM
  • Marked As Answer byfathatsme Tuesday, August 04, 2009 6:35 AM
  •  
_SuDhiR_  Tuesday, August 04, 2009 6:34 AM
thanx a lot!!!
i had forgot to use adapter.Fill(dsSet);

now can ya help me wid the update operation f the same ???
fathatsme  Tuesday, August 04, 2009 6:36 AM

You can use google to search for other answers

Custom Search

More Threads

• DataGridViewComboBoxCell error
• Need help updating data to multiple tables
• Exact Text Positioning Inside a DataGridView Cell
• Function - Check Duplicate Key Value in DataGridView
• InkOverlay.Renderer.Draw Method not working with dotnet obfuscator
• Can't view Access Database in a grid for a User Control
• Adding chkbox to GridView
• TableAdapter Update Problem With Foreign Key in Child Table
• adding new row in datagridview
• convert values