Insert 'Text' Datatype into database

Posted on 2004-11-30
Last Modified: 2010-04-23
I am trying to pass data from an ASP.Net page to a stored procedure. I am passing the data through a Business Layer to a Data Layer and then to the Stored Proceddure.

aspx codebehind:

   create(textbox1.text, textbox2.text)

Business Layer:

   Function create(ByVal name, ByVal bulkContent)
   End Function

Data Layer:

    Function create(ByVal name As String, ByVal bulkContent As ?)   <<< not sure what datatype to use for text db datatype
        ------SQL to send the Stored Procedure
    End Function

Stored Procedure:

    *** I don't Know

I am not sure on the rest of the Data Layer nor how to do a Stored Procedure to accept a text datatype. I have to use Text because VarChar(8000) is not enough room.

Can anyone help me on this one.


Question by:JsonTerre1
    LVL 25

    Expert Comment

    have you tried
    LVL 25

    Expert Comment

    you can lookup the types in the help under namespace
    LVL 8

    Accepted Solution

    Your .net code should treat it the same way as it treats a varchar, so use it as a string.

    Something like:

    aspx codebehind:

       create(textbox1.text, textbox2.text)

    Business Layer:

       Function create(ByVal name as string, ByVal bulkContent as string)
       End Function

    Data Layer:

        Public Sub create(ByVal name As String, ByVal bulkContent As string)
            ------SQL to send the Stored Procedure
            Dim oConnection As New SqlConnection(ConnectionString)
            Dim oCommand As New SqlCommand("spMyProc", oConnection)
            Dim oTransaction as SqlTransaction
          oCommand.CommandType = CommandType.StoredProcedure
          oTransaction = oConnection.BeginTransaction
          oCommand.Transaction = oTransaction

          oCommand.Parameters("@Name").Value = name
          oCommand.Parameters("@BulkContent").Value = bulkContent

            Catch ex As Exception
          If Not oTransaction Is Nothing Then oTransaction.Rollback()
          If Not oTransaction Is Nothing Then oTransaction.Dispose()
          If Not oCommand Is Nothing Then
                  If Not oCommand.Connection Is Nothing AndAlso Not oCommand.Connection.State = ConnectionState.Closed Then oCommand.Connection.Close()
          End If
            End Try
        End Function

    Stored Procedure:

        Create Procedure spMyProc
            @Name varchar(200),
            @BulkContent text
            Insert Into tblData(Name, BulkContent) Values(@Name, @BulkContent)
    LVL 1

    Author Comment

    Thank you very much. That worked great

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now