We help IT Professionals succeed at work.
Get Started

C# Properties value passing to another form

ANINDYA
ANINDYA asked
on
274 Views
Last Modified: 2013-12-17
Experts
I have a question .
Please see the screen shots and the code and you will be able to know what is my problem and what I want to do.
Please see both the screen shots.
Thanking you,
This is the code of the form where the Plus sign is there and also the MemberId textbox is also there.That is Form1.

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.SqlClient;
using System.Text.RegularExpressions;

namespace CDShop
{
    public partial class Form_BorrowSection : Form
    {
        public Form_BorrowSection()
        {
            InitializeComponent();
        }
        Int32 memberid { get; set; }
        public void getMemberid()
        {
            Int32 id;
            id = Convert.ToInt32(textBox_MemberID.Text);
            memberid = id;
        }


Here is the code of the Form2 .

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.SqlClient;

namespace CDShop
{
    public partial class Form_Borrowed_Items : Form
    {
        public Form_Borrowed_Items()
        {
            InitializeComponent();
        }

        private void Form_Borrowed_Items_Load(object sender, EventArgs e)
        {
            label1.Text = fb.memberid;//fb is the Form1 object


            string b = "Borrowed";
            string query = "select * from Table_Borrow where MemberID=@parameter1 and Status LIKE '" + b.ToString() + "' ";
            using (SqlConnection con = new SqlConnection("Data Source=INVENTOR-1D70F6\\SQLEXPRESS;Initial Catalog=AnindyaCD;Integrated Security=SSPI"))
            {
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    cmd.Parameters.AddWithValue("@parameter1", MemberID);

                    using (SqlDataAdapter ad = new SqlDataAdapter(query, con))
                    {
                        ad.SelectCommand = cmd;
                        DataSet ds = new DataSet();
                        ad.Fill(ds, "Table_Borrow");
                        dataGridView5.DataSource = ds.Tables[0];
                    }
                }
            }
        }
    }
}

Open in new window

error.JPG
error.JPG
Comment
Watch Question
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE