try this...
MyConnection = new SqlConnection("server=127.0.0.1;database=PictureShare;Trusted_Connection=yes");
MySQLDataAdapter = new SqlDataAdapter();
SessionCmd String = "INSERT INTO tmPicIndex (UserID, PicName, PicDesc) VALUES ('" & user & "', '" & savename.Value & "', 0)";
MyCommand = new SqlCommand(SessionCmd, MyConnection);
MyCommand.Connection.Open();
try
{
MyCommand.ExecuteNonQuery();
}
catch(SQLException Exp)
{
if (Exp.Number == 2627)
{
}
else
{
}
}
MyCommand.Connection.Close();