Public Function
not working from class when i use a class and connection then it is not working
Public Function connection()
con = New SqlConnection("server=DESKTOP-BNDMR5K;database=irfanansari;integrated security=true")
Return con
End Function
Public Function getvalueto() As SqlCommand
com = New SqlCommand("select * from sale", Me.con)
adpt = New SqlDataAdapter
adpt.SelectCommand = com
table = New DataTable
adpt.Fill(table)
MsgBox("Record Save Sussfully Now", MsgBoxStyle.Information, "Saved Record")
End Function
not working when i use like this
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'GridView1.DataSource = c.getvalueto
'GridView1.DataBind()
End Sub
What I have tried:
<pre>Public Function connection()
con = New SqlConnection("server=DESKTOP-BNDMR5K;database=irfanansari;integrated security=true")
Return con
End Function
Public Function getvalueto() As SqlCommand
com = New SqlCommand("select * from sale", Me.con)
adpt = New SqlDataAdapter
adpt.SelectCommand = com
table = New DataTable
adpt.Fill(table)
MsgBox("Record Save Sussfully Now", MsgBoxStyle.Information, "Saved Record")
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'GridView1.DataSource = c.getvalueto
'GridView1.DataBind()
End Sub