1
Answer

system.componentmodel.container is missing how to add it?

Vikas Ahlawat

Vikas Ahlawat

14y
15k
1
I have converted a VB.NET project in C# (win application),
After conversion In Designer.cs under

InitializeComponent()
            {
           
                this.components = new System.ComponentModel.Container();


it show that form does not contain the definition of Components
and when i try to add reference then in reference here system.componentmodel.DataAnnotations appear
system.componentmodel.container not appear

And when i start a new window app. then under this i use this.com... then it does not give this type of error.
So how remove this error
Answers (1)
0
Sanjeeb Lenka

Sanjeeb Lenka

NA 15.3k 2.4m 9y
try like this.
 
 
string s = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

SqlConnection con = new SqlConnection(s);

SqlCommand cmd = new SqlCommand("select * from table where Id='" + value + "'", con);

cmd.CommandType = CommandType.Text;

cmd.Parameters.AddWithValue("@Id",value);



cmd.Connection = con;

con.Open();



SqlDataReader dr = cmd.ExecuteReader();

while (dr.Read())

{

TextBox1.Text = dr["username"].ToString();

TextBox2.Text = dr["password"].ToString();

TextBox3.Text = dr["fname"].ToString();

TextBox4.Text = dr["gender"].ToString();

}



dr.Close();

con.Close();