Hi. I create the table (MS SQL 2008)

IdUrovniaKatHerakl - HierarchyId (not null primary key),
KatName nvarchar(max) not null,
LevelKat as RowId.GetLevel()
KatId - int
KatOpisanie nvarchar(max)

How can I using C# in Visual Studio 2010 (RC) insert new data into this table?

I do this: create DataSet and Create TableAdapter for this table

DataSet1 ds = new DataSet1();
   DataSet1TableAdapters.KategoriiFotoTableAdapter kategoriiFotoTableAdapter = new DataSet1TableAdapters.KategoriiFotoTableAdapter();
    DataSet1.KategoriiFotoRow newKategoriiFotoRow = ds.KategoriiFoto.NewKategoriiFotoRow();
         SqlHierarchyId her;
          SqlHierarchyId gt =  SqlHierarchyId.Null;

          newKategoriiFotoRow.IdUrovniaKatHerakl = (her.GetDescendant(gt,null));
           newKategoriiFotoRow.KatName = TextBox1.Text;
    newKategoriiFotoRow.KatOpisanie = "'eto opisanie";


But it does not work, eror in "newKategoriiFotoRow.IdUrovniaKatHerakl = (her.GetDescendant(gt,null));"
help me. Roman

Please read the rules before posting again - We strive to be a community geared towards the professional. We strongly encourage all posts to be in full-sentence English.

>How can I using C# in Visual Studio 2010 (RC) insert new data into this table?

SqlConnection cn=new SqlConnection("put_connection_string");
SqlCommand cmd=new SqlCommand("insert into table (col1,col2) values (@col1,@col2)");



Many thanks for your recommendations and the help. It has very much helped me to resolve the given problem.
Excuse for my errors.

This article has been dead for over six months. Start a new discussion instead.