i have enabled FileStream and created this table on sql server:
CREATE TABLE dbo.PictureTable
(
PkId int Primary Key IDENTITY (1, 1),
Id uniqueidentifier NOT NULL Unique ROWGUIDCOL Default newid(),
Description nvarchar(64) NOT NULL,
FileSummary varbinary(MAX),
FileData varbinary(MAX) FileStream NULL
)
and use this code snippet for inserting rows :
private void btnInsert_Click(object sender, EventArgs e)
{
using (TransactionScope transactionScope = new TransactionScope())
{
SqlConnection sqlConnection1 = new SqlConnection(@"Data Source=REZA-PC;Initial Catalog=FileStreamTest;Integrated Security=True");
SqlCommand sqlCommand1 = sqlConnection1.CreateCommand();
sqlCommand1.CommandText = @"Insert Into PictureTable (Description ,FileData ) Values(cast( NEWID() as nvarchar(64)),Cast('' as varbinary(max))) ";
sqlConnection1.Open();
sqlCommand1.ExecuteNonQuery();
sqlConnection1.Close();
}
}
no error
but the code do not insert any row to database where as the identity of PkId filed changes every time i click btnInsert!
i can use same query in sql server managment studio and it inserts rows without any problem
Insert Into PictureTable (Description ,FileData ) Values(cast( NEWID() as nvarchar(64)),
Cast('' as varbinary(max)))