VB Language RRS feed

  • Question

  • User888242859 posted

     Can someone translate the following to VB language please?



    using System;

    using System.Data;

    using System.Configuration;

    using System.Collections;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    using System.Data.SqlClient;

    using System.Data.Sql;

    using System.IO;

    public partial class ImageUpload : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)



    protected void btnUpload_Click(object sender, EventArgs e)


    Stream imgStream = fuImage.PostedFile.InputStream;

    int imgLen = fuImage.PostedFile.ContentLength;

    string imgName = txtImageName.Text;

    string imgJob = TxtImageJob.Text;

    string imgAddress = TxtImageAddress.Text;

    byte[] imgBinaryData = new byte[imgLen];

    int n = imgStream.Read(imgBinaryData,0,imgLen);

    //use the web.config to store the connection string

    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["TestConnectionString1"].ConnectionString);

    SqlCommand command = new SqlCommand("INSERT INTO Image (imagename,image,Job,Address) VALUES ( @img_name, @img_data, @img_job, @img_address)", connection);

    SqlParameter param0 = new SqlParameter("@img_name", SqlDbType.NVarChar, 20);

    param0.Value = imgName;


    SqlParameter param1 = new SqlParameter("@img_data", SqlDbType.Image);

    param1.Value = imgBinaryData;



    SqlParameter param2 = new SqlParameter("@img_job", SqlDbType.NVarChar, 20);

    param2.Value = imgJob;


    SqlParameter param3 = new SqlParameter("@img_address", SqlDbType.NVarChar, 20 );

    param3.Value = imgAddress;



    int numRowsAffected = command.ExecuteNonQuery();




    Monday, September 22, 2008 6:33 PM

All replies

  • User-340921419 posted

    Imports System

    Imports System.Data

    Imports System.Configuration

    Imports System.Collections

    Imports System.Web

    Imports System.Web.Security

    Imports System.Web.UI

    Imports System.Web.UI.WebControls

    Imports System.Web.UI.WebControls.WebParts

    Imports System.Web.UI.HtmlControls

    Imports System.Data.SqlClient

    Imports System.Data.Sql

    Imports System.IO

    Public Partial Class ImageUpload
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        End Sub
        Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim imgStream As Stream = fuImage.PostedFile.InputStream
            Dim imgLen As Integer = fuImage.PostedFile.ContentLength
            Dim imgName As String = txtImageName.Text
            Dim imgJob As String = TxtImageJob.Text
            Dim imgAddress As String = TxtImageAddress.Text
            Dim imgBinaryData As Byte() = New Byte(imgLen - 1) {}
            Dim n As Integer = imgStream.Read(imgBinaryData, 0, imgLen)
            'use the web.config to store the connection string
            Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("TestConnectionString1").ConnectionString)
            Dim command As New SqlCommand("INSERT INTO Image (imagename,image,Job,Address) VALUES ( @img_name, @img_data, @img_job, @img_address)", connection)
            Dim param0 As New SqlParameter("@img_name", SqlDbType.NVarChar, 20)
            param0.Value = imgName
            Dim param1 As New SqlParameter("@img_data", SqlDbType.Image)
            param1.Value = imgBinaryData
            Dim param2 As New SqlParameter("@img_job", SqlDbType.NVarChar, 20)
            param2.Value = imgJob
            Dim param3 As New SqlParameter("@img_address", SqlDbType.NVarChar, 20)
            param3.Value = imgAddress
            Dim numRowsAffected As Integer = command.ExecuteNonQuery()
        End Sub
    End Class

    Monday, September 22, 2008 6:43 PM
  • User888242859 posted

    Thanks for your help.

    My application is not working yet. I needed in VB for school. When debugging I get the following error

    <a href="javascript:void(window.open('<%# "FullImage.ashx?ImID="+ Eval("ImageID")%>','_blank','toolbar=no,menubar=no'))" >

    System.FormatException: Input string was not in a correct format.


    Monday, September 22, 2008 10:42 PM
  • User201647903 posted

    First - try this website to convert C# to VB: http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx

    Second, try this to open a new window with VB/JavaScript:  

    <script type="text/javascript">
     function openyourwindow()

    Third - it looks like you are trying to open a window maximized?  I'm not quite sure exactly what you are tying to do with your window.open script, but check out this web site, maybe it will give you some information to do what you are trying to do... http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

    And don't forget to mark it as the answer if it helps you - thanks!

    Tuesday, September 23, 2008 10:11 AM