c# - SQLite Parameter Issue with Guids -


While I'm having problems matching the guides while using parameters, when I type something like userguide = 'Grid Here'. This works, but Userguide = @GuideHair is not like that. Anyone have any ideas?

(user guded text not primary key, first name text, last name text)

Sample data:

  Log in user (user guad, first name, last name) value ('e7bf9773-8231-44af-8d53-e624f0433 943', 'Bobby', 'bomstone')  

Delete statement (working):

  Delete from user where userguude = 'e7bf9773-8231-44af-8d53-e624f0433 943'  

Delete statement (work Is not doing):

  Remove from user where userguid = @ userguide  

Here is a C # program that is showing my problem:

 using the  system; Using System.Data.SQLite; Namespace SQLite_Sample_App {class program} {static zero main (string [] args) {doo}; Console.Read (); } Static zero () (SQLiteConnection MyConnection = New SQLiteConnection ("Data Source =: Memory:; Version = 3; New = True")) {MyConnection.Open (); SQLiteCommand MyCommand = MyConnection.CreateCommand (); MyCommand.CommandText = @ "Users in User's User (User Guid, First Name, Last Name) VALUES ('e7bf9773-8231-44af-8d53-e624f0433 943', 'Bobby')," Table User (User's not a Gud Text Primary Key , First name text, last name TEXT) "", 'Bobstown'); "; MyCommand.ExecuteNonQuery (); MyCommand.CommandText = "Selection Number (*) from users where userguude = 'e7bf9773-8231-44af-8d53-e624f0433 943'"; Console.light line ("method one: {0}", MyCommand.ExecuteScalar ()); MyCommand.Parameters.AddWithValue ("@ UserGuid", New Guid ("e7bf9773-8231-44af-8d53-e624f0433 943")); MyCommand.CommandText = "Selection Number (*) from users where userguide = @ userguide"; Console.lightline ("method two: {0}", micromaxexteslasar ()); Well it seems that AddParamWithValue translates for a Guid 16byte representative, so I think that I really need to translate it into all the grids. Strings first ... kinda annoying.   

Just try passing the string of the GUID in your AddWithValue call, rather than the GUID object.

instead of

  MyCommand.Parameters.AddWithValue ("@UserGuid", New Guid ("e7bf9773-8231-44af-8d53-e624f0433 943"));  

Do this:

  MyCommand.Parameters.AddWithValue ("@UserGuid", "e7bf9773-8231-44af-8d53-e624f0433 943");  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -