C# Tutorial 11:Database values in textbox if select Combobox

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 70

  • @pinar2213
    @pinar2213 11 лет назад +12

    This is how it worked in my program:
    String sEid = rdr["Eid"].ToString();
    String sName = rdr["name"].ToString();
    String sSurname = rdr["surname"].ToString();
    String sAge = rdr["age"].ToString();
    Eid_txt.Text = sEid;
    Name_txt.Text = sName;
    Surname_txt.Text = sSurname;
    Age_txt.Text = sAge;
    PS. Im using MsSql database

    • @murugans5287
      @murugans5287 10 лет назад

      hello mam mssql only support int value so you should give your colum number instead of colum name
      thanks

    • @pinar2213
      @pinar2213 10 лет назад

      Hi,
      The code that I have shared in my previous post, worked as it was for me...
      Hope it helps you too.

    • @sandeepnair5482
      @sandeepnair5482 9 лет назад

      Pinar U.S. Thanx this comment helped me a lot...........

    • @travelwithnaeemhasan
      @travelwithnaeemhasan 9 лет назад

      +Pinar U.S. you are great you really solve a complex problem in this tutorial thank for this

    • @hidayaturrahman7897
      @hidayaturrahman7897 7 лет назад

      assign index no instead of names

  • @Alphalos10
    @Alphalos10 11 лет назад +1

    Got to say Tutorials 11 and 12.. Although not exactly what I was after, taken bits from it, and it was very helpful.
    One thing though, I've always been taught not to copy and paste code, strange to see someone actually doing it.

    • @dmm10000
      @dmm10000 7 лет назад

      copy and pasting is fine for small snippets of code ...for speed - but you;re correct ....really a lot of the code in the example should have been placed in its own method and called where needed

  • @gian-lucanardini9706
    @gian-lucanardini9706 9 лет назад +8

    he is working in MySQL database I'm in sql database if you the same this code will work for youstring sID = reader.GetString(reader.GetOrdinal("ID"));
    string sname = reader.GetString(reader.GetOrdinal("name"));
    string sSurname = reader.GetString(reader.GetOrdinal("surname"));
    string sAge = reader.GetString(reader.GetOrdinal("age"));that works for me

    • @enderbiradam6954
      @enderbiradam6954 8 лет назад

      Love you. Video is hard to follow, but what i needed was this, exactly.

    • @deshanfernando7982
      @deshanfernando7982 6 лет назад

      Thanks a lot bro... that was a great help

  • @suconnottu64
    @suconnottu64 8 лет назад

    thanks your tutorials are helpfull eventhough i am programming in vb net the libraries are the same

  • @logicfirst7959
    @logicfirst7959 8 лет назад +1

    You are a beast my brother, thank you for saving my butt in the project.

  • @grady730
    @grady730 5 лет назад +3

    How the hell did you pass a string into GetString() when it requires an int variable?

  • @orlanncruz6447
    @orlanncruz6447 8 лет назад

    excelente video tutorial me servira en mi proyecto de residencia muy buen aporte .
    saludoss.. me gustan tus videos (Y)..

  • @matsuabiabiabi
    @matsuabiabiabi 10 лет назад

    All your tutorials were very helpful. Thank you for all your videos :)

  • @astronom201
    @astronom201 10 лет назад

    Corrected:
    1)
    void Fillcombo()
    {
    string constring = "server=localhost; user=root;database=mydb;DefaultTableCacheAge=30;charset=utf8";
    string Query = "select * from mydb.towary ;";
    MySqlConnection conDatabase = new MySqlConnection(constring);
    MySqlCommand cmdDataBase = new MySqlCommand(Query, conDatabase);
    MySqlDataReader myReader;
    try
    {
    conDatabase.Open();
    myReader = cmdDataBase.ExecuteReader();
    comboTowary.Items.Clear();
    //MessageBox.Show("Deleted");
    while (myReader.Read())
    {
    string ID = myReader.GetString("idTowary");
    string sName = myReader.GetString("nazwaTowaru");
    comboTowary.Items.Add(ID + "_"+ sName);
    }
    2)
    private void comboTowary_SelectedIndexChanged(object sender, EventArgs e)
    {
    string constring = "server=localhost; user=root;database=mydb;DefaultTableCacheAge=30;charset=utf8";
    string Query = "select * from mydb.towary WHERE CONCAT_WS('_',idTowary,nazwaTowaru)='"+ comboTowary.Text + "';";

  • @jmgcloquendero
    @jmgcloquendero 7 лет назад

    Dude you're awesome, thanks for all this tutorials

  • @evilgogeta4
    @evilgogeta4 5 лет назад

    Hi Brother there is a worst case that which id will we get if there are two same names?

  • @juancarlosfarias3173
    @juancarlosfarias3173 10 лет назад

    Is it posible to use only one connection? Why do you have to create a new one each time??? Tnks four your help.

  • @TheShakalab
    @TheShakalab 11 лет назад

    Excellent tuto..Many thanks

  • @nishantvivek725
    @nishantvivek725 8 лет назад +1

    Can we type a name in combobox rather than selecting it? It will be helpful in cases where you have many names to scroll and select!

    • @dmm10000
      @dmm10000 7 лет назад

      yes i agree - that's called autocomplete where matching entries appear as you type each letter of the search term

  • @ravikantha1
    @ravikantha1 6 лет назад

    Very Helpful. Thank You

  • @cheetah7170
    @cheetah7170 7 лет назад

    can i do this with a text box instead? where when he types a id no. all values show in the textbox

  • @NVNRAI
    @NVNRAI 5 лет назад

    I have 3 buttons in a form in c# which goes to the same page but how do I get the names of respective buttons saved in the sql server?

  • @JunLee000
    @JunLee000 8 лет назад

    My problem is when I add or Save a new data (ex. new employee) it doesn't show in the combo box immediately , I have to rerun the system again for the combo box to show the new data. .please help how to show the new data immediately in the combo box?

  • @hidayaturrahman7897
    @hidayaturrahman7897 7 лет назад

    at the time 9:23 why we are not assigning directly to the textboxs instead of strings or int what ever .... as there any benefit please answer.

  • @SunShine24024
    @SunShine24024 4 года назад

    Very nice 👍

  • @ChristosG
    @ChristosG 7 лет назад

    What about WPF comboboxes.. The SelectedIndexChange doesn't exist and the SelectedValue changes after the code behind has run.

  • @subhamsamir9209
    @subhamsamir9209 6 лет назад

    how to do the reverse process, sir. I want to control the data of combo box in case some data is inserted into a textbox. please help

  • @dangerleyba
    @dangerleyba 11 лет назад

    my COBOL professor said to me that you will never write a program, you will tailor an existing program to fit your needs.

  • @Alexander1stable
    @Alexander1stable 10 лет назад

    Hy man! If you have THE SAME NAME in the database TWICE, the program will not work properly.
    Look at "mark" --> it's show just the last row with the eid=7. The row with eid=2 is not saved in the combox.
    Why? If anyone know how to fix this please leave a message! Thanks!

  • @djragner
    @djragner 9 лет назад +1

    Nice job!

  • @SCSC324
    @SCSC324 10 лет назад

    you do wrong query... look at 11:23 when you select first "mark" you should get eid=2 , but you get eid=7. column name is not unique so when you select name from edata where name="mark" you get 2 record and while loop use last record ...

  • @foodcraver765
    @foodcraver765 11 лет назад

    I am using MSSQL.In MSSQL I have used ToString in place of varchar,what should I use for Int type?please help

  • @sabeenmalik7582
    @sabeenmalik7582 6 лет назад +3

    cannot convert from 'string' to 'int' ???? plz help

  • @santelices1
    @santelices1 10 лет назад +3

    Does anyone else expererince that nothing happens? nothing is shown in the combobox?

    • @20sieghart
      @20sieghart 9 лет назад

      +Daniel Santelices just add .SelectedItem on the combobox you used in the query

  • @himanshukhare1992
    @himanshukhare1992 8 лет назад +2

    How to perform same operation in ASP.NET MVC 4 Razor ???
    Please let me know if somebody knows ?

  • @muruligowda2985
    @muruligowda2985 6 лет назад

    Please tell me how to display date database to textbox when select combobox..

  • @rajatkumargupta2483
    @rajatkumargupta2483 7 лет назад

    Sir,
    I want my second comboBox show data according to the data selected in First comboBox.
    example,
    In ComboBox1, i want to select the gender like (male or female),
    and according to comboBox1 selection , the comboBox2 show the name of only Male (if selected) or only Female (if selected )

  • @gajendran8439
    @gajendran8439 6 лет назад +4

    rdr.GetString("Breed").ToString(); error

  • @cabalsdemon
    @cabalsdemon 9 лет назад

    i made listbox2 and i had to put where name= '"+ comboBox1.SelectedItem +"'
    by the way i am using a different table to get the combobox value
    when i click on another item in combobox it doesnt change the vallue in the listbox2 it stays the same value

  • @jacksonbr4759
    @jacksonbr4759 8 лет назад

    Thank very much!

  • @gedeom10
    @gedeom10 7 лет назад

    What if there are exactly two names in the database?

  • @kaivalyajamkhindi3770
    @kaivalyajamkhindi3770 10 лет назад

    thanx bro.....

  • @tcgamingyt6528
    @tcgamingyt6528 3 года назад

    Super

  • @siddharthasharma3866
    @siddharthasharma3866 8 лет назад

    if there is one radio button then how to do ???????

  • @travelwithnaeemhasan
    @travelwithnaeemhasan 9 лет назад

    Error cannot convert from 'string' to 'int' how can i handle it? please help

    • @Zenit0244
      @Zenit0244 9 лет назад +3

      int itemId = myReader.GetInt32(myReader.GetOrdinal("ItemId"));

  • @hirucool1
    @hirucool1 11 лет назад

    thanx bro

  • @nameersummitsolution1799
    @nameersummitsolution1799 4 года назад

    how to perform same operation in android studio? please help anyone

  • @bhoir89
    @bhoir89 6 лет назад

    Love You Man...!

  • @RankOoze
    @RankOoze 7 лет назад

    how to do in webpages

  • @astronom201
    @astronom201 10 лет назад

    You have error, mark its 2, and allways is id=7

  • @GiancarloCarccamo
    @GiancarloCarccamo 11 лет назад

    thank dude

  • @bouhlalabdessamad5366
    @bouhlalabdessamad5366 8 лет назад

    do this in java please

  • @farhanzahid9785
    @farhanzahid9785 8 лет назад

    kindly share the source code its imp for beginers

    • @dmm10000
      @dmm10000 7 лет назад

      you heard the kid !! - yes please share the code

  • @aryan1997able
    @aryan1997able 8 лет назад

    ta ch zhe chenakr psmam :D

  • @brandoncox469
    @brandoncox469 4 года назад

    Code doesn't work, bud

  • @fbibad2262
    @fbibad2262 5 лет назад

    quality sucks AND WHY DO YOU RECORD ONLY YOUR MOUSE WHY NOT THE WHOLE SCREEN ITS SO HARD TO WATCH

  • @MicrosiMe
    @MicrosiMe 8 лет назад

    Its really time wasting task to follow these examples, while they are very good to learn from. I dont understand the idea why the developer just dont leave the code written? To save us from following them for hours? and saving us from small mistakes?
    I spent hours making this example, and I got "
    unable to connect to any of the specified mysql hosts"
    So, please next time when you do something, do it complete. and leave the code to download it

  •  2 года назад

    Thank you!