problem with uniqueidentifier in select!

J

Jeff

ASP.NET 2.0

The select in the code below throws an exception when I tested it: Incorrect
syntax near 'f'

This is the select Debug.Write wrote to the output window:
SELECT Id, Info FROM Test where Id = f24a27c7-630f-411e-aac0-b571e8b440a6

public override TestInfo GetTest(System.Guid id)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
string sql = "SELECT Id, Info FROM Test where Id = " + id.ToString();
Debug.Write("sql = " + sql);
SqlCommand cmd = new SqlCommand(sql, cn);
cmd.CommandType = CommandType.Text;
cn.Open();
}
}

What am I doing wrong here?

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top