Hello,
Is there any way I can replace the data adapter with sql reader to fill datatable.
Dim SQLobj As New SqlCommand("L_Sy")
SQLobj.Parameters.AddWithValue("@Title", Dy_Title)
SQLobj.Parameters.AddWithValue("@Year_Ref1", Dy_Year_Ref1)
SQLobj.Parameters.AddWithValue("@Year_Ref2", Dy_Year_Ref2)
SQLobj.Parameters.AddWithValue("@FaxNumber", Dy_FaxNumber)
SQLobj.Parameters.AddWithValue("@Attn", Dy_Attn)
SQLobj.CommandType = CommandType.StoredProcedure
SQLobj.Connection = sql.GetConnection
clsFrmmain.Populate(SQLobj)
Public Sub Populate(ByVal Command As SqlCommand)
'Accept command as string and fill the datatable with the result of sql query
' Test_Str = "Test"
Dim dt = New DataTable
Try
adapter = New SqlDataAdapter()
adapter.SelectCommand = Command
dt.BeginLoadData()
adapter.Fill(dt)
dt.EndLoadData()
Command.Connection.Close()
Command.Dispose()
Data_Table = dt
Catch MyException As SqlException
MessageBox.Show("Stored procedure Error: MySQL code: " &
MyException.Number & " " &
MyException.Message)
End Try
End Sub
ps. This is rather more code for you to write an could possibly run more slowly as well.