Error Retrieving Single Data Using ExecuteScalar Method

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2007
Posts: 10
Reputation: wonder_gal is an unknown quantity at this point 
Solved Threads: 0
wonder_gal wonder_gal is offline Offline
Newbie Poster

Error Retrieving Single Data Using ExecuteScalar Method

 
0
  #1
Apr 12th, 2007
Hi, I receive this error "No default member found for type 'Guid'." when I run my application.

db = New SqlConnection(GetConnectionString())
db.Open()

Dim strSQL As String
strSQL = "SELECT GUID FROM MyLog WHERE MyID = '" & strID & "'"

strGUIDTracker = GetSingleData(strSQL)

..................


Function GetSingleData(ByVal sqlText As String) As String
        Dim sd As String
        Dim oConn As SqlConnection
        oConn = New SqlConnection(GetConnectionString())
        Dim strSQLCmd As SqlCommand = New SqlCommand(sqlText, oConn)
        strSQLCmd.Connection.Open()
        sd = strSQLCmd.ExecuteScalar(System.Data.CommandBehavior.CloseConnection)
        Return sd
    End Function

The highlighted line is the statement where the error occured at. I've tested my SQL statements, it really contains a single record.

Can someone please kindly explain to me why am I getting this error here? Thanks alot.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 23
Reputation: bruce2424 is an unknown quantity at this point 
Solved Threads: 0
bruce2424 bruce2424 is offline Offline
Newbie Poster

Re: Error Retrieving Single Data Using ExecuteScalar Method

 
0
  #2
Oct 12th, 2008
follow the url, it explain how to ExecuteScalar

http://vb.net-informations.com/ado.n...sqlcommand.htm
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC