i tried to cast it, it throws an error. This is the row definition
ID UniqueIdentifier NOT NULL
this is the cast
empGUID = (Guid)rstEmployees.Fields["ID"].Value;
Would it make sense to anyone that it worked last night and stopped working today...I dont even think anything changed.
Loading

Kirtan PatelRank #292 · 8.6K reputationPosted Jun 11, 2009, 8:49 PM EDT
private void button1_Click(object sender, EventArgs e) { // Insert GuiD in Database Guid c = Guid.NewGuid(); textBox1.Text = c.ToString(); SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"); con.Open(); SqlCommand comm = new SqlCommand("insert into users(id) values('"+c.ToString()+"')",con); comm.ExecuteNonQuery(); //Show Inserted GUID in DataGridView SqlCommand comm2 = new SqlCommand("select * from users",con); SqlDataAdapter da = new SqlDataAdapter(comm2); DataSet ds = new DataSet(); da.Fill(ds,"v"); dataGridView1.DataSource = ds.Tables[0]; //Retrive the Guid In MessageBox SqlCommand comm3 = new SqlCommand("select * from users",con); SqlDataReader reader = comm3.ExecuteReader(); while (reader.Read()) { Guid x = (Guid)(reader["id"]); MessageBox.Show(x.ToString()); } }Kirtan PatelRank #292 · 8.6K reputationPosted Jun 11, 2009, 11:00 AM EDT
patrickRank #4,458 · 342 reputationPosted Jun 11, 2009, 12:31 PM EDT
patrickRank #4,458 · 342 reputationPosted Jun 11, 2009, 1:04 PM EDT
patrickRank #4,458 · 342 reputationPosted Jun 12, 2009, 10:04 AM EDT
Kirtan PatelRank #292 · 8.6K reputationPosted Jun 12, 2009, 8:47 PM EDT