views:

180

answers:

2

here is a little problem ...

string SQL = @"INSERT INTO [Answers] ([UserID],[QuestionID],[SelectedIndex]) 
  VALUES(@uid,@qid,@sin)";
    SqlParameter[] par = new SqlParameter[] { 
    new SqlParameter("@uid",this.userid),
    new SqlParameter("@qid",this.questionid),
    new SqlParameter("@sin",this.qOptions.SelectedIndex)
    };

this does not work ... Why not? i dunno, but the firs one is bigint in SQL (microsoft 2005) and in dotNET side its an int ... second one is a an SQL uniqueidentifier while its a string in dotNEWT but it works that way i have experience .. third one is an integer in SQL and int in dotNET ... since dotNET does not have any major malfunction, what is my major malfunction? :) thank you sargeant in advance :)))

+1  A: 

uniqueidentifier should map to Guid rather than string, I believe. What happens if you make it a Guid instead (just for a test value)? See the SqlDbType enumeration docs for a list of mappings.

It would also help if you'd say in what way it doesn't work, by the way. That's always a good idea when you're reporting a problem. Does it throw an exception?

Jon Skeet
A: 

SqlGuid's Implicit operator expects a Guid, not an int. Alternatively, there are explicit constructors for String, Byte[] and int as well.

Sören Kuklau