hi frndz i m making a project on hospital management in cSharp n in that i have made a form of "patient registration" in that i have taken ten textbox for diff entry....
n i want to coonnect this form with patient detail table in sql in that table i have taken 21 columns so i cannot understand how to insert data in sql bcz when i try to insert data through sqlparameter an expection occurs that table has more columns than parameter used in this form so can sumbody tell me coding for how to insert,show data in sql plzzzzzzzzzzzzzzz plzzzzzzzzzzzzzzzzzzzzz help me

this is third thread plzzzzzzzzzzzzzzzz i haven't get any rep

plzzzzzzzz help me

thx in advance plzzzzzzzzzz help i need it urgently

8 Years
Discussion Span
Last Post by aarushik

i also try to bind the data with table but this coding also not work so could u tell me wat to do

string constr = @"Data Source=.;Initial Catalog=LifelineHospital;
                Integrated Security =True;";
        public PatientRegistrationForm()

        private void button1_Click(object sender, EventArgs e)
            string constr=@"Data Source=.;Initial Catalog=LifelineHospital;
                Integrated Security =True;";
            SqlConnection conn = new SqlConnection(constr);
            catch (SqlException ex)
                MessageBox.Show("Error in connection ..." + ex.Message);
            string sqlstr = "SELECT * from Patient_Detail";
            SqlDataAdapter  dAdapter = new SqlDataAdapter(sqlstr, conn);
            DataSet dset = new DataSet();
            dAdapter.TableMappings.Add("Table", "Patient_Detail");
            DataViewManager dviewmanager = new DataViewManager();
            dviewmanager = dset.DefaultViewManager;
            this.comboBox1.DataSource = dviewmanager;
            this.comboBox2.DataSource = dviewmanager;
            this.textBox1.DataBindings.Add("Text", dset, "Patient_Detail.PatientId");
            this.textBox2.DataBindings.Add("Text", dset, "Patient_Detail.PatientName");
            this.textBox3.DataBindings.Add("Text", dset, "Patient_Detail.PatientAge");
            this.comboBox1.DisplayMember = "Patient_Detail.Gender";
            this.textBox4.DataBindings.Add("Text", dset, "Patient_Detail.Address");
            this.textBox5.DataBindings.Add("Text", dset, "Patient_Detail.ContactRes");
            this.textBox6.DataBindings.Add("Text", dset, "Patient_Detail.Mobile");
            this.textBox10.DataBindings.Add("Text", dset, "Patient_Detail.AdmitDate");
            this.comboBox1.DisplayMember = "Patient_Detail.Department";
            this.textBox7.DataBindings.Add("Text", dset, "Patient_Detail.RoomNo");
            this.textBox8.DataBindings.Add("Text", dset, "Patient_Detail.ReferedFrom");
            this.textBox9.DataBindings.Add("Text", dset, "Patient_Detail.TreatmentBy");

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.