Hi, I don't get it I cannot get this to work, can somebody give me a hint
Table1 contains a field Id which is a GUID as primary key and DATA a string,
I want to insert a new row but it does not work.
void gv_RowCommand(O bject sender, GridViewCommand EventArgs e)
{
ClientScript.Re gisterStartupSc ript(GetType(), "MyAlert2",
"alert('Command =" + e.CommandName + "');", true);
if (e.CommandName == "New")
{
SqlCommand cmd = new SqlCommand();
//First problem How do I make a GUID?
SqlGuid g = new SqlGuid("3AAAAA AA-BBBB-CCCC-DDDD-2EEEEEEEEEEE");
//Second problem, how do I use the GUID in the Insert
cmd.CommandText = "INSERT INTO dbo.Table1
Values("+g.ToSt ring()+",'tst') "; //?????
cmd.CommandType = CommandType.Tex t ;
SqlConnection sqlConnection1 = new
SqlConnection(S qlDataSource1.C onnectionString );
cmd.Connection = sqlConnection1;
sqlConnection1. Open();
cmd.ExecuteNonQ uery();
sqlConnection1. Close();
GridView1.DataB ind();
}
}
Table1 contains a field Id which is a GUID as primary key and DATA a string,
I want to insert a new row but it does not work.
void gv_RowCommand(O bject sender, GridViewCommand EventArgs e)
{
ClientScript.Re gisterStartupSc ript(GetType(), "MyAlert2",
"alert('Command =" + e.CommandName + "');", true);
if (e.CommandName == "New")
{
SqlCommand cmd = new SqlCommand();
//First problem How do I make a GUID?
SqlGuid g = new SqlGuid("3AAAAA AA-BBBB-CCCC-DDDD-2EEEEEEEEEEE");
//Second problem, how do I use the GUID in the Insert
cmd.CommandText = "INSERT INTO dbo.Table1
Values("+g.ToSt ring()+",'tst') "; //?????
cmd.CommandType = CommandType.Tex t ;
SqlConnection sqlConnection1 = new
SqlConnection(S qlDataSource1.C onnectionString );
cmd.Connection = sqlConnection1;
sqlConnection1. Open();
cmd.ExecuteNonQ uery();
sqlConnection1. Close();
GridView1.DataB ind();
}
}
Comment