[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Load Record by value in textbox

I need to be able to load a record into muliple textboxes by entering a value into one of the textboxes.

How can I do this?
0
enlightec
Asked:
enlightec
  • 2
1 Solution
 
YurichCommented:
i think you have to be more detailed on this...

1. load a record from where?? - a data base or flat file or dataset or xml or what??
2. do you want to enter a value, press button and trigger the event, or you want start typing and as soon as something is typed, you want to trigger your event, or you want to type something as soon as focus leaves the textobx, you want to trigger your event.

regs,
yurich

0
 
enlightecAuthor Commented:
1. load a record from where?? - a data base or flat file or dataset or xml or what??

From an Access database

2. do you want to enter a value, press button and trigger the event, or you want start typing and as soon as something is typed, you want to trigger your event, or you want to type something as soon as focus leaves the textobx, you want to trigger your event.

As soon as a value is entered I want it to retrieve the values for each textbox
0
 
YurichCommented:
there're really several approaches, one of them:

suggesting that you want to do it in the OnButton_Click method of the button after all data is entered in all texboxes.

// add this directive to all using directive
using System.Data.OleDbClient;
...

// that's in your button handling event
OleDbConnection conn = new OleDbConnection();
// connection string can of course be different
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb";
conn.Open();

OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM table_name WHERE something = '" + txtCriterion.Text + "'";
OleDbDataReader dreader = cmd.ExecuteReader();

if( dreader.Read())
{
  txtValue1.Text = dreader[ "column_name1" ].ToString();
  txtValue2.Text = dreader[ "column_name2" ].ToString();
}

dreader.Close();
conn.Close();

it should give you a go,
good luck,
yurich
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now