Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MySQL - VB.NET - MD5

Posted on 2010-11-15
3
Medium Priority
?
644 Views
Last Modified: 2012-05-10
I'm sure this is going to be an "it's easy when you know how..." but here goes.

If I run this on a MySQL command line I get what I expect:
mysql> SELECT MD5('test text') AS strMD5;
+----------------------------------+
| strMD5                        |
+----------------------------------+
| 1e2db57dd6527ad4f8f281ab028d2c70 |
+----------------------------------+
1 row in set (0.00 sec)

However if I do this:
            strSQL = "SELECT MD5('test text') AS strMD5"
            objSQLCommand.CommandText = strSQL
            objDataAdapter = New MySqlDataAdapter()
            objDataAdapter.SelectCommand = objSQLCommand


            objDataSet = New DataSet
            objDataSet.DataSetName = "xxxx"

            objDataAdapter.Fill(objDataSet, "yyyy")

            objDataSet.WriteXml(Response.OutputStream)

I get:
<xxxx>
  <yyyy>
    <strMD5>MWUyZGI1N2RkNjUyN2FkNGY4ZjI4MWFiMDI4ZDJjNzA=</strMD5>
  </yyyy>
</xxxx>

Why is the result different?
Mike
0
Comment
Question by:Reklaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
kraiven earned 1000 total points
ID: 34135784
Hi,

The value you are seeing in the .Net code is a Base64String encoding of the HEX text you are returning from the query.

E.G.
byte[] bytes = Encoding.UTF8.GetBytes ("1e2db57dd6527ad4f8f281ab028d2c70");
var outp = Convert.ToBase64String(bytes);
System.console.WriteLine(outp);

Open in new window


0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 1000 total points
ID: 34135828
If you output the schema, you will see a confirmation of kraiven's comment:
untitled.PNG
0
 
LVL 1

Author Closing Comment

by:Reklaw
ID: 34135864
As I said... Easy when you know how 8-)
Many thanks to you both
Mike
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question