Hi.
I have a temporary data table,where when i click the save button,the temporary values will be saved into database.
Now i want to save the values as a unique identifier in ms. sql database.
And when i want to view the database table in gridview,i wan to view the uniqueidentifier values as varchar in gridview.
Any ideas guys?
Here's my save to database code (.cs)
protected void BtnSendToDatabase_Click(object sender, EventArgs e)
{
string strId = string.Empty;
for (int count = 0; count < dt.Rows.Count; count++)
{
strId = strId + dt.Rows[count][0].ToString() + ", ";
}
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "INSERT INTO Table1 (Company_Name) VALUES ('" + strId + "')";
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
|