Click here to Skip to main content
15,796,982 members
Home / Discussions / C#
   

C#

 
AnswerRe: Async await error Pin
Mycroft Holmes1-May-20 13:00
professionalMycroft Holmes1-May-20 13:00 
GeneralRe: Async await error Pin
Carlos581-May-20 13:08
Carlos581-May-20 13:08 
GeneralRe: Async await error Pin
Mycroft Holmes1-May-20 13:18
professionalMycroft Holmes1-May-20 13:18 
AnswerRe: Async await error Pin
Carlos582-May-20 5:01
Carlos582-May-20 5:01 
GeneralRe: Async await error Pin
Dave Kreskowiak2-May-20 5:52
mveDave Kreskowiak2-May-20 5:52 
GeneralRe: Async await error Pin
Luc Pattyn2-May-20 10:18
sitebuilderLuc Pattyn2-May-20 10:18 
AnswerRe: Async await error Pin
Gerry Schmitz3-May-20 19:34
mveGerry Schmitz3-May-20 19:34 
AnswerRe: Async await error Pin
Richard Deeming5-May-20 2:16
mveRichard Deeming5-May-20 2:16 
Avoid async void methods | You’ve Been Haacked[^]

Try something like this:
C#
private void Form1_Load(object sender, EventArgs e)
{
    _ = OnFormLoadAsync();
}

private async Task OnFormLoadAsync()
{
    try
    {
        DataSet ds = await Task.Run(() => LoadCustomers());
        mycombo.DataSource = ds.Tables[0];
        mycombo.ValueMember = "code";
        mycombo.DisplayMember = "cust_name";
    }
    catch (Exception error)
    {
        MessageBox.Show("Error.... " + erro.Message);
    }
}

private DataSet LoadCustomers()
{
    const string query = "SELECT * FROM Customers ORDER BY cust_name";
    
    using (OleDbConnection con = new OleDbConnection(conex))
    using (OleDbCommand cmd = new OleDbCommane(query, con))
    {
        OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
        DataSet ds = new DataSet();
        adapter.Fill(ds);
    }
}
But as others have said, loading thousands of records into a combobox is not a good idea.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

QuestionHow to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
boozeeh11-May-20 6:01
boozeeh11-May-20 6:01 
AnswerRe: How to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
Luc Pattyn1-May-20 8:43
sitebuilderLuc Pattyn1-May-20 8:43 
GeneralRe: How to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
boozeeh11-May-20 13:20
boozeeh11-May-20 13:20 
GeneralRe: How to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
Luc Pattyn1-May-20 14:43
sitebuilderLuc Pattyn1-May-20 14:43 
GeneralRe: How to get a list og Outgoing MSMQ queues (without mention its knowing name) ? Pin
boozeeh12-May-20 2:31
boozeeh12-May-20 2:31 
QuestionUse DLL in C# Pin
Member 1481764029-Apr-20 16:16
Member 1481764029-Apr-20 16:16 
AnswerRe: Use DLL in C# Pin
Dave Kreskowiak29-Apr-20 17:56
mveDave Kreskowiak29-Apr-20 17:56 
AnswerRe: Use DLL in C# Pin
Luc Pattyn29-Apr-20 18:11
sitebuilderLuc Pattyn29-Apr-20 18:11 
AnswerRe: Use DLL in C# Pin
Eddy Vluggen30-Apr-20 10:34
professionalEddy Vluggen30-Apr-20 10:34 
AnswerRe: Use DLL in C# Pin
kalberts2-May-20 5:40
kalberts2-May-20 5:40 
QuestionCan not compare a file and same file stored in mysql - sha256 Pin
wilcodk29-Apr-20 8:40
wilcodk29-Apr-20 8:40 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Luc Pattyn29-Apr-20 9:07
sitebuilderLuc Pattyn29-Apr-20 9:07 
GeneralRe: Can not compare a file and same file stored in mysql - sha256 Pin
wilcodk30-Apr-20 2:32
wilcodk30-Apr-20 2:32 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Mycroft Holmes29-Apr-20 13:18
professionalMycroft Holmes29-Apr-20 13:18 
GeneralRe: Can not compare a file and same file stored in mysql - sha256 Pin
wilcodk30-Apr-20 2:28
wilcodk30-Apr-20 2:28 
AnswerRe: Can not compare a file and same file stored in mysql - sha256 Pin
Eddy Vluggen30-Apr-20 7:34
professionalEddy Vluggen30-Apr-20 7:34 
QuestionCompare string time to timer time (noobie) Pin
Member 1481029228-Apr-20 6:36
Member 1481029228-Apr-20 6:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.