C# MS Access Database Tutorial 10 # Database values in textbox if select Combobox

C# MS Access Database Tutorial 10 # Database values in textbox if select Combobox

ProgrammingKnowledge

9 лет назад

59,615 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@ProgrammingKnowledge
@ProgrammingKnowledge - 15.07.2014 01:46

Ответить
@jeremythom2414
@jeremythom2414 - 28.07.2014 23:29

Hi, I've been following your videos and so far they are perfect. I finally hit a problem.

Using your code for my documents, after I add the four

txt_eid.Text = reader ["EID"].ToString(); lines,

I can still select everything from the combobox, but it stopped linking to the text boxes.

Before I added these lines it would link combobox to textbox, but wouldn't replace it,

Thanks for any help.

Ответить
@tankpigSTS
@tankpigSTS - 06.08.2014 15:51

Can't get mine to work...give me no errors but just doesn't show the data in the text boxes

Ответить
@allancaldz
@allancaldz - 16.09.2014 06:55

cant duplicate surname , textbox value of 1 surname = 1

Ответить
@erickhilton2875
@erickhilton2875 - 30.11.2014 13:47

Gracias por todo

Ответить
@gillesymien822
@gillesymien822 - 06.12.2014 13:59

You are wonderful. Every things I think about, you talk about it!!!!! Many thanks to you!!!

Ответить
@csianahmed
@csianahmed - 23.11.2015 08:45

please send the link of the video that explains the code you used inside the combo box

Ответить
- 08.03.2016 13:35

Dual record MARK not work well.
See EID 1 and 12

Ответить
@nehalel-shaboury4495
@nehalel-shaboury4495 - 17.04.2016 17:24

That was my code..... but unfortunately there was no response.... Does anyone have an idea where the problem lies?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace LifeCycleEnergyAssessment
{
public partial class YearlyOperationEnergy : Form
{
private OleDbConnection connection = new OleDbConnection();
public YearlyOperationEnergy()
{
InitializeComponent();
connection.ConnectionString @"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\Users\Nehal92\Desktop\Access Database\Primary Energy Conversion Factors.accdb;
Persist Security Info=False;";
}

private void button2_Click(object sender, EventArgs e)
{
this.Hide();
DemolitionEnergy DE = new DemolitionEnergy();
DE.Show();
}

private void YearlyOperationEnergy_Load(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "select * from PrimaryEnergyConversionFactor";
command.CommandText = query;
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
comboBox1.Items.Add(reader["EnergySource"].ToString());
comboBox2.Items.Add(reader["EnergySource"].ToString());
comboBox3.Items.Add(reader["EnergySource"].ToString());
comboBox4.Items.Add(reader["EnergySource"].ToString());
comboBox5.Items.Add(reader["EnergySource"].ToString());
}
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error" + ex);
}
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "select * from PrimaryEnergyConversionFactor where EnergySource=' " + comboBox1.Text + " ' ";
command.CommandText = query;
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
textBox18.Text = reader["PrimaryConversionFactor"].ToString();
}
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error" + ex);
}
}
}
}

Ответить
@vladimirblum441
@vladimirblum441 - 09.05.2016 19:08

O-O-ps! I found my mistake in syntax Sorry !

Ответить
@delform1989
@delform1989 - 14.10.2016 00:42

I'm curious how did you make that for the first time. Did it was a book or you search information in forum. Byt the way, really good example ;)

Ответить
@anthonramos3576
@anthonramos3576 - 04.03.2017 14:38

How about ID ? If I want ID to show from combox and show from textbox ? What I declare ?

Ответить
@sagarkawthankar3876
@sagarkawthankar3876 - 06.06.2017 21:40

Whenever I select any item from combo box, corresponding values are not shown in text boxes but when I select another value from combo box, the previous values are displayed. Please help! I have done the exact same thing. Also, when I double click on combo box, studio creates a function private void pickname_SelectionChanged(object sender, SelectionChangedEventArgs e)
I changed it to function you have but still same thing is happening!

Ответить
@mbs2488
@mbs2488 - 24.10.2017 15:30

Very Good !

Ответить
@bilalvanloon7906
@bilalvanloon7906 - 04.01.2018 18:56

Does someone know how to let the combobox "query" fill in the textboxes when you have the First and Last name in the combobox instead of only the FirstName from the example lesson #10?

Ответить
@angeloromanoliveros4441
@angeloromanoliveros4441 - 04.03.2018 17:48

why its not working to me damn

Ответить
@brettbyrd
@brettbyrd - 19.03.2018 19:44

I have learned quite a bit by watching this series. I do have one issue I hope you can help resolve. If I am using this to keep track of employees or products, how can I get it to update the ComboBox when I add/delete/update anything on this form without closing the form and opening it again?

Ответить
@luuquangtinh
@luuquangtinh - 22.11.2018 12:22

Many thanks !!

Ответить
@thehartzhans8785
@thehartzhans8785 - 14.12.2018 18:08

Hai
Thnx for your informative video's
But .....
I don't want to have sql code in my C# code, I want to use a file, on my desktop, witch contains my sql code
How can i execute sutch a file in C#

Ответить
@toshiii8646
@toshiii8646 - 24.12.2018 11:07

Ok it's not appearing in any of my textboxes

Ответить
@makhosingobe2162
@makhosingobe2162 - 08.03.2019 20:24

Thanks for the video. How do I retrieve data from related tables, like student name from student table, students results from reports tables, these tables are linked with student number (primary key in student table and foreign key in results table) ? I have tried, my sql works on msacess but not on C#.
Thank you in advance

Ответить
@frallen9787
@frallen9787 - 17.03.2019 18:00

TY MY INDIAN/ARAB FRIEND!

Ответить
@draganatosovic7541
@draganatosovic7541 - 13.01.2020 16:50

Man, you're the LEGEND of C# :D

Ответить
@mariamrafiq3425
@mariamrafiq3425 - 17.02.2020 18:19

mere pas to nhi rha ye code...

Ответить
@marcstephencorpuz4804
@marcstephencorpuz4804 - 09.03.2021 19:45

hi i have followed every line of codes but im getting "System.Data.OleDb.OleDbException: 'Data type mismatch in criteria expression.' " help pls

Ответить