PHP SQL到VB.Net的转换

I am having trouble converting my PHP SQL query to Vb.Net.

This is my PHP code:

<?php 
$ServerName = "Farbod-PC\SQLExpress";
$User = "sa";
$Pass = "admin123";
$DB = "Account";

$user = sql_clean($_GET['Username']);
$passhash = sql_clean($_GET['Password']);

$connectionInfo = array("UID"=>$User,"PWD"=>$Pass,"DATABASE"=>$DB);
$conn = sqlsrv_connect( $ServerName, $connectionInfo) or die('Database connect Fail.');


if( $conn ) {
} else {
     echo " <br> Connection could not be established. <br> <br>";
     die( print_r( sqlsrv_errors(), true));
}

$exec = sqlsrv_query($conn, "SELECT nEMID, nAuthID, sUserPass FROM tAccounts where sUsername = '$user'");
$AccountData = sqlsrv_fetch_array($exec);
$file = file('LauncherInfo.txt', FILE_IGNORE_NEW_LINES);

$sql = "SELECT nEMID, nAuthID, sUserPass FROM tAccounts where sUsername = '$user'";
$params = array();
$options =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$stmt = sqlsrv_query( $conn, $sql , $params, $options );

$row_count = sqlsrv_num_rows( $stmt );

    foreach ($file as $line) {
        $line = trim($line);
        if ($line) {
            $splitLine = explode(' = ',$line);
            $data[$splitLine[0]] = $splitLine[1];
        }
    }

    if($exec)

{
    if($row_count != 1)
    {
        die('wud');
    }

    if ($AccountData ['nAuthID'] == -2) {
        die ('INV');
    } else if ($AccountData ['nAuthID'] == -1) {
        die ('BAN');
    } else if ($AccountData ['nAuthID'] == 0) {
        die ('EVR');
    } else if ($AccountData ['nAuthID'] == 1) {
        if ($data['MAINT'] == "True") {
        die ('MM');
        }
    } else if ($AccountData ['nAuthID'] == 2) {
        //Continue and allow user to log in.
    } else {
        die ('NAUTH');
    }

    $PlaintxtPass = $AccountData['sUserPass'];
    $PlaintxtnEMID = $AccountData['nEMID'];
    if (MD5($PlaintxtPass) == $passhash)
    {
        $Token = RandomToken(35);

        $setToken = null;

        if (sqlsrv_num_rows(sqlsrv_query($conn, "SELECT * FROM tTokens WHERE nEMID = '".$PlaintxtnEMID."'")) >= 1)
        {
            sqlsrv_query($conn, "DELETE FROM tTokens WHERE nEMID = '".$PlaintxtnEMID."'");
            $setToken = sqlsrv_query($conn, "INSERT INTO tTokens (nEMID, sToken) VALUES('".$PlaintxtnEMID."', '".$Token."')");
        }
        else
            $setToken = sqlsrv_query($conn, "INSERT INTO tTokens (nEMID, sToken) VALUES('".$PlaintxtnEMID."', '".$Token."')");      

        if ($setToken)
            die('OK#'.$Token.'#'.$AccountData ['nAuthID']);
        else
            die('SetToken Error');
    }
    else
    {
        die('wud');
    }
}
else
{
    die('Query Failed');
}

sqlsrv_close();

function sql_clean($str)
{
    $search  = array("\\", "\0", "
", "", "\x1a", "'", '"');
    $replace = array("", "", "", "", "", "", "");
    return str_replace($search, $replace, $str);
}

function RandomToken( $length )
{
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $str = "";
    $size = strlen( $chars );
    for( $i = 0; $i < $length; $i++ ) {
        $str .= $chars[ rand( 0, $size - 1 ) ];
    }

    return $str;
}
?>

This is my Vb.net code so far:

Imports System.Net
Imports System.Data.SqlClient

Public Class Form1

    Dim SQLHost As String = "Farbod-PC\SQLEXPRESS"
    Dim SQLUserName As String = "sa"
    Dim SQLPassword As String = "admin123"
    Dim Server As String = "Account"

    Dim conn As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & Server & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";")

    Dim strSQL As String

    Dim exec As String = "SELECT nEMID, nAuthID, sUserPass FROM tAccounts where sUsername = 'user'"

End Class

I'm not sure which way I should go about doing this. I would appreciate it if anyone could help. Thanks.

Farbod, It seems as though you're asking a pretty vague and broad question here. StackOverflow is great if you need help with specific problems, but it seems that what you really need are some VB.NET tutorials.

Although one thing I would say is this; Stored Procedures are your friends.