overload resolution failed because no accessible 'new' can be called with these arguments..
the error shows at the Dim dataadapter As New SqlDataAdapter(sqlCmd, connection)

Imports System.Data.SqlClient

Public Class Form1

    Private Sub BtnGenResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGenResult.Click
        Dim ConnectionString As String = "Data Source=(local)\SQLEXPRESS; AttachDbFilename=D:\PKBW Batching System Data and Config\BatchingDatabase\Config\PK_BatchingConfig.mdf; ;User ID=sa;Password=1;"
        Dim sqlCmd As New SqlCommand
        Dim connection As New SqlConnection(ConnectionString)
        Dim code As String
        Dim dataadapter As New SqlDataAdapter(sqlCmd, connection)
        Dim ds As New DataSet
        code = Val(TextBoxIngCode.Text)
        connection.Open()
        dataadapter.Fill(ds, "Titles_table")
        connection.Close()
        sqlCmd.Connection = connection
        sqlCmd = New SqlCommand _
                ("SELECT FormulaCode, BatchAbsNo, FormulaName, BatchStartTime, BatchFinishTime FROM dboBatchReportHeader WHERE FormulaCode = '" & TextBoxIngCode.Text & "'")
        DataGridViewResult.DataSource = sqlCmd

    End Sub
End Class

please help me to solve this issue..

Try somethong like this

   Dim cmd As New SqlCommand
        Dim ds As New DataSet
        Dim da As New SqlDataAdapter
        Dim conn As New SqlConnection("Ur connection")


        With cmd
            .Connection = conn
            .CommandTimeout = 3000
            .CommandType = CommandType.text
            .CommandText = "SQL code"

        End With

        da = New SqlDataAdapter
        da.SelectCommand = cmd

        ds = New DataSet
        da.Fill(ds)

I think there's no SqlDataAdapter constructor like SqlDataAdapter(SqlCommand, SqlConnection). Maybe it should be like

Dim sql as String = "Select * from table1"
Dim dataadapter As New SqlDataAdapter(sql, connection)

thanks dimasalang, i tried your method and now that error is gone but now i have a new error.

the error is = SqlException is unhandled, Invalid object name 'dboBatchReportHeader'.
the error points at dataadapter.Fill(ds)

this is my current code

Imports System.Data.SqlClient

Public Class Form1

    Private Sub BtnGenResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGenResult.Click
        Dim ConnectionString As String = "Data Source=(local)\SQLEXPRESS; AttachDbFilename=D:\PKBW Batching System Data and Config\BatchingDatabase\Report\PK_BatchingReport.mdf; ;User ID=sa;Password=1;"
        Dim sqlCmd As New SqlCommand
        Dim sql As String = "SELECT FormulaCode, BatchAbsNo, FormulaName, BatchStartTime, BatchFinishTime FROM dboBatchReportHeader WHERE FormulaCode = '" & TextBoxIngCode.Text & "'"
        Dim connection As New SqlConnection(ConnectionString)
        Dim dataadapter As New SqlDataAdapter(sql, connection)
        Dim code As String
        Dim ds As New DataSet
        code = Val(TextBoxIngCode.Text)
        connection.Open()
        dataadapter.Fill(ds)
        connection.Close()
        sqlCmd.Connection = connection
        DataGridViewResult.DataSource = sqlCmd


    End Sub
End Class

thanks in advance

Seems like your code coudn't find the table named 'dboBatchReportHeader'.

My bad. It was suppose to be BatchReportHeader only. Thanks!

My pleasure. Let us know if you have anymore issue with that or mark this thread as solved if your issue was solved already.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.