[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Insert 'Text' Datatype into database

Posted on 2004-11-30
Medium Priority
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
  • 2
LVL 25

Expert Comment

ID: 12713863
have you tried system.data.sqltypes.sqlstring
LVL 25

Expert Comment

ID: 12713870
you can lookup the types in the help under system.data.sqltypes namespace

Accepted Solution

rfgkev earned 500 total points
ID: 12714092
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)

Author Comment

ID: 12742433
Thank you very much. That worked great

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

834 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