Posts tagged dataset

How to set command Timeout for getData() in TableAdapter

One of the disadvantages when we using tableadapter to retrieve the data from database is they do not provide property to set command timeout (SHIT). This giving me a huge headache for my project which most of the entire project is using tableadapter instead of creating my own DAL or class.
After do some research on the internet, there is 1 ways to add command timeout in tableadapter dataset (.xsd file) which is

create new property inside partial class:
Double click on xxxTableAdaper and it will show you behind code in .vb file of xsd file. Add this code inside Partial Public Class xxxDataTableAdapter

Namespace xxxTableAdapters
    Partial Public Class yyyTableAdapter
        Public WriteOnly Property CommandTimeout() As Integer
            Set(ByVal value As Integer)
                Dim i As Integer = 0
                While (i < Me.CommandCollection.Length)
                    If (Me.CommandCollection(i) IsNot Nothing) Then
                        Me.CommandCollection(i).CommandTimeout = value
                    End If
                    i = (i + 1)
                End While
            End Set
        End Property
    End Class
End Namespace

And how you use it, you just add 1 line of code:

            Dim dt As New DataSet1TableAdapters.AddressTableAdapter
            dt.CommandTimeout = 120
            gridview1 = dt.GetData()

Notes:
xxxTableAdapters , xxx you replace with the name of .xsd file
yyyTableAdapter you replace with the name of table adapter

This code is tested in visual studio 2008 and 2005

  • Share/Bookmark

ASP.NET: How to read XML Data String to Dataset


The output of XML String:

<?xml version="1.0" encoding="utf-8" ?>
- <NewDataSet>
- <Table>
 <CONDOM>Durex</CONDOM>
 <SIZE>XL</SIZE>
 <QTY>123</QTY>
 <COLOR>616</COLOR>
 </Table>
 </NewDataSet>

In order to convert from XML to dataset, this is the code:
Read the rest of this entry »

  • Share/Bookmark

ASP.NET – Convert CSV to Dataset

In this post I will show you how to convert from .csv files to dataset in ASP.NET
Read the rest of this entry »

  • Share/Bookmark

Connecting asp.net to Sql server 2005 stored procedures into dataset

This article demonstrates how to use ASP.NET and ADO.NET with Visual Basic .NET to create and to call a Microsoft SQL Server stored procedure with an input parameter and an output parameter.

1 step create store procedure


Create Procedure GetAuthorsByLastName1 (@au_lname varchar(40), @RowCount int output)
as

select * from authors where au_lname like @au_lname;

/* @@ROWCOUNT returns the number of rows that are affected by the last statement. */
select @RowCount=@@ROWCOUNT

Call the stored procedure in asp.net code
Read the rest of this entry »

  • Share/Bookmark