Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

    Sub BindData()
       Dim SalesOrderConn As New SqlClient.SqlConnection(Session.Item("ConnectionString"))
       Dim SalesOrderdat As New SqlClient.SqlDataAdapter
       Dim SalesOrderdts As New DataSet

       SalesOrderdat.SelectCommand.CommandText = "SELECT * FROM tblSalesOrder WHERE Approved = 0 AND Cancelled = 0"
       SalesOrderdat.SelectCommand.Connection = SalesOrderConn
       SalesOrderdat.SelectCommand.ExecuteReader()

       SalesOrderdat.Fill(SalesOrderdts)
       dgSalesOrder.DataSource = SalesOrderdat
       SalesOrderConn.Close()
   End Sub

 

Regarding to the above codes:

most of the time I used drag and drop method.

I am trying to use it in programmatic way but it don't work. Why??

George C.K. Low

Posted

the solution is

 

Sub BindData()
       Dim SalesOrderConn As New SqlClient.SqlConnection(Session.Item("ConnectionString"))
       Dim SalesOrderdat As New SqlClient.SqlDataAdapter
       Dim SalesOrderdts As New DataSet

       If SalesOrderConn.State = ConnectionState.Closed Then
          SalesOrderConn.Open()
       End If

       SalesOrderdat.SelectCommand = New SqlClient.SqlDataAdapter
       SalesOrderdat.SelectCommand.CommandText = "SELECT * FROM tblSalesOrder WHERE Approved = 0 AND Cancelled = 0"
       SalesOrderdat.SelectCommand.Connection = SalesOrderConn

       SalesOrderdat.Fill(SalesOrderdts)
       dgSalesOrder.DataSource = SalesOrderdat
       SalesOrderConn.Close()
   End Sub

George C.K. Low

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...