من این object سازی رو داخل کلاس جداگانه انجام دادم و داخل Form اصلی این کلاس رو فراخوانی میکنیم ولی داخل کلاسم textbox رو نمیشناسه؟
کلاسم به صورت زیره:
public class product
{
public void add()
{
SqlConnection cnn = new SqlConnection();
try
{
cnn.ConnectionString = "Data Source=.;Initial Catalog=Market;Integrated security=true";
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "spm_insert_product";
cmd.Connection = cnn;
p0.ParameterName = "@pid";
p0.DbType = DbType.String;
p0.SqlDbType = SqlDbType.VarChar;
p0.Size = 10;
p0.Value = textBox1.Text;
p0.Direction = ParameterDirection.Input;
cmd.Parameters.Add(p0);
cnn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
}
if (cnn.State == ConnectionState.Open)
cnn.Close();
}