Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

retrieve data from database using c#

$
0
0
I am new to c# and this is the second program that I am writing. I am trying to retrieve data from an Access Database in C#. I am running into a little bit into a wall because when I compile the program I get an error. I know the error is because there are different types of fields and I don't know how to retrieve them. Here is my routine to retrieve some fields but the idea is to be able to retrieve all fields (10 in total):
private voidtxtSearch_KeyPress(objectsender,KeyPressEventArgse)
   {

if (e.KeyChar == (char)13)

           if(string.IsNullOrEmpty(txtSearch.Text))

           dataGridView.DataSource = operatorsBindingSource;

    else   

varquery =fromointhis.operDataSet.operators

                     where o.Oper_FName.Contains(txtSearch.Text) || o.Pos_Id == txtSearch.Text || o.Oper_HireDate == txtSearch.Text || o.Oper_BirthDate == txtSearch.Text || o.Oper_Other.Contains(txtSearch.Text)

    

selecto;

                    dataGridView.DataSource = query.Tolist();

                }

            }

        }

Pos_Id is an int, Oper-HireDate and Oper_BirthDate are date fields. I need to retrieve them when I run the query or is there another way that I can retrieve all the fields and assign them accordingly. For instance, select from * and then somehow from the DataSource allocate them individually. And be able to update the record. Thank you in advance

     


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>