Error when trying to run a stored procedure

J

Jeff Thur

I am getting this error when trying to run a stored
procedure:
[MissingMemberException: No default member found for
type 'DataSet'.]

Microsoft.VisualBasic.CompilerServices.LateBinding.LateInd
exGet(Object o, Object[] args, String[] paramnames) +1361
ASP.Baldwin41_aspx.Button1_Click(Object sender,
EventArgs e) +66
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
+83

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEv
entHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent
(IPostBackEventHandler sourceControl, String
eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent
(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277





Here is my program

Function GetResults

Dim ConnString As String = "server='(local)'; user
id='sa'; password='fritz'; database='Cutis'"
Dim sproc As String = "EMSTONY"
Dim paramsize As Integer = (7)

Dim Conn As New SqlConnection(ConnString)
Dim cmd As New SqlCommand(sproc)
cmd.CommandType = CommandType.StoredProcedure

Dim param as New SqlParameter("@txtSort", DbType.String,
paramSize)
param.Value = txtSort.Text
cmd.Parameters.Add(param)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet("Dataset")
da.TableMappings.Add("Table", "DataGrid1")

Try
conn.Open()
da.Fill(ds)
Catch ex As Exception
'Error handling here
Finally
If (conn.State = ConnectionState.Open) Then
conn.Close()
End If

conn.Dispose()

End Try


Return (ds)



End Function

Sub Button1_Click(sender As Object, e As EventArgs)
DataGrid1.DataSource = GetResults(TxtSort)
DataGrid1.DataBind()
End Sub


Any HELP GREATLY APPRECIATED.
 
G

Guest

Hi Jeff,

Not too sure why you are getting this error. The code looks good. Anyway, i
just made a search for the error. This is what i find..

1. MissingMemberException is thrown when there is an attempt to dynamically
access a class member that does not exist.

2. Also suggest you turn Option Strict On. This will elminate these kinds of
problems at compile time, because your program will not compile.

The function calling SP looks fine. I think the problem exists
in the way you are binding the datasource to the datagrid in the button click
event. Can you check on it.

Need any help, do post a msg back...

Happy Coding
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top