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

x
?
Solved

Insert 'Text' Datatype into database

Posted on 2004-11-30
4
Medium Priority
?
213 Views
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)
          create(name,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.

-J


0
Comment
Question by:JsonTerre1
  • 2
4 Comments
 
LVL 25

Expert Comment

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

Expert Comment

by:RonaldBiemans
ID: 12713870
you can lookup the types in the help under system.data.sqltypes namespace
0
 
LVL 8

Accepted Solution

by:
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)
          create(name,bulkContent)
   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
        Try
      oCommand.CommandType = CommandType.StoredProcedure
      oCommand.Connection.Open()
      SqlCommandBuilder.DeriveParameters(oCommand)
      oTransaction = oConnection.BeginTransaction
      oCommand.Transaction = oTransaction

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

      oCommand.ExecuteNonQuery()
      oTransaction.Commit()
        Catch ex As Exception
      If Not oTransaction Is Nothing Then oTransaction.Rollback()
        Finally
      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()
              oCommand.Dispose()
      End If
        End Try
    End Function

Stored Procedure:

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

Author Comment

by:JsonTerre1
ID: 12742433
Thank you very much. That worked great
0

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