views:

88

answers:

1

I have

byte[] a = HashEncrypt("a");

with

public byte[] HashEncrypt(string password)
{
    SHA512Managed sha = new SHA512Managed();
    byte[] hash = sha.ComputeHash(UnicodeEncoding.Unicode.GetBytes(password));
    return hash;
}

I want to save byte[] a to my database. My database field is a varbinary(64). I'm using SQL Server 2008. I want to know the insert query with C# code.

I am using ADO.NET

+1  A: 

Not quite sure how you're doing this as pointed out in the comments under your question, but I've added a byte[] to my db table by using a SqlParamenter inside of a SqlCommand.

SqlCommand cmd = new SqlCommand("insert into binaryTable (example) values (@example)",connection);
cmd.Parameters.Add(new SqlParameter("@example",HashEncript("password"));
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
Aaron
thanks really it's really helpful for me thanks again. LINQ-to-SQL? Entity Framework? NHibernate? will you tell me about them.If i want to use them how to .thanks again
shamim