Hello:
two way:
1.what's wrong for the codes? or 2.If I want use "select * from table where id = guid",how to write the
sqlStetement,I know there's
a way to write the sql,but how to write it?
I only use "'"+Encoding.Default.GetString(aGuid.ToByteArray()) +"'",It can't
work.
How to write it?

This looks as working for me:

           FbConnection c = new FbConnection(csb.ToString());
           c.Open();

           FirebirdClientFactory factory = FirebirdClientFactory.Instance;

           DbCommand createTable = factory.CreateCommand();
createTable.CommandText = "CREATE TABLE GUID_TEST (GUID_FIELD CHAR(16) CHARACTER SET OCTETS)";
           createTable.Connection = c;
           createTable.ExecuteNonQuery();
           createTable.Dispose();

           Guid newGuid = Guid.Empty;
           Guid guidValue = Guid.NewGuid();

           // Insert the Guid
           DbCommand insert = factory.CreateCommand();
insert.CommandText = "INSERT INTO GUID_TEST (GUID_FIELD) VALUES (@GuidValue)";
           insert.Connection = c;
           DbParameter insertParameter = factory.CreateParameter();
           insertParameter.ParameterName = "@GuidValue";
           insertParameter.DbType = DbType.Guid;
           insertParameter.Value = guidValue;
           insert.Parameters.Add(insertParameter);
           insert.ExecuteNonQuery();
           insert.Dispose();

           // Select the value
           DbCommand select = factory.CreateCommand();
select.CommandText = "SELECT * FROM GUID_TEST WHERE GUID_FIELD = @GuidValue";
           select.Connection = c;
           DbParameter selectParameter = factory.CreateParameter();
           selectParameter.ParameterName = "@GuidValue";
           selectParameter.DbType = DbType.Guid;
           selectParameter.Value = guidValue;
           select.Parameters.Add(selectParameter);

           DbDataReader r = select.ExecuteReader();
           if (r.Read())
           {
               newGuid = r.GetGuid(0);
           }

           c.Close();



--
Carlos Guzmán Álvarez
Vigo-Spain

http://carlosga.blogspot.com/

"When you don't code, you tend to become one of those architects who thinks 
everything is possible" ( Anders Hejlsberg )



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to