how can i databind for a windows application?

good day everyone,

i tried to do databind() in a windows application but it wasunsuccessful.

is there any way to extract data from several tables like the databind() method in win application i used it before in web application and it was working fine any idea anyone

plz help...urgent....thanks..



Answer this question

how can i databind for a windows application?

  • Paul Chin

    private void displayData()

    {

    openConnection();

    if (assess_NameComboBox.Items.Count != 0)

    {

    dataGrid1.Visible = true;

    saveMarksBtn.Visible = true;

    cmd = conn.CreateCommand();

    SqlDataAdapter sda;

    DataSet ds;

    string sql = cmd.CommandText;

    sql = "Select Class_Student.Student_ID, Student.Student_Name From Class_Student, Student Where Sub_Code = '" + subjectComboBox.SelectedValue + "' And Section = '" + sectionComboBox.SelectedValue + "' And Year = '" + yearComboBox.SelectedValue + "'And Sem_No = '" + sem_NoComboBox.SelectedValue + "'And Class_Student.Student_ID = Student.Student_ID";

    sda = new SqlDataAdapter(sql, conn);

    ds = new DataSet();

    dataGrid1.DataSource = ds;

    }

    else

    {

    MessageBox.Show("No assessment information is save yet. \n Please click assessment tab to add assessment.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

    dataGrid1.Visible = false;

    saveMarksBtn.Visible = false;

    }

    conn.Close();

    }


  • Kent Waldrop Au07

    Please don't post in multiple forums. You're using C++ What's the code look like



  • cpeterka

    If you started with VB and moved to C#, why did you post in the c++ forum I'm moving this to the C# forum.



  • KeithPhillips

    Because winforms is a connected model, databinding happens when you pass in a datasource.



  • kalpna

    for ur info,i'm now using c#.net for this exercise.

    Thanks for your reply.


  • Stefan.Dobrev

    Like I said, you don't need a databind method, just set the data source, and it will bind. What does your code look like



  • vinxter

    sorry for post to the wrong place.

    But I still don't understand how to make it works in win form.

    can anyone pls help...........


  • rosapdx

    the codes below is vb codes that i used in web form,but i dono how change it to win form since i couldn't find databind(). any idea

    'Populated the Subject DropDownList with the subjects that the lecturer is teaching from the database

    Sub FillSubjectList()

    OpenConnection()

    Sql = "Select Distinct Sub_Code From Lecturer_Subject Where Lec_ID = '" & Username & "'"

    Cmd = New SqlCommand(Sql, Con)

    Sdr = Cmd.ExecuteReader()

    Marks_Subject.DataSource = Sdr

    Marks_Subject.DataBind()

    Cmd.Dispose()

    Con.Close()

    End Sub


  • how can i databind for a windows application?