Sql Error in ProjectTracker Library 3.03-071127

Sql Error in ProjectTracker Library 3.03-071127

Old forum URL: forums.lhotka.net/forums/t/4372.aspx


Burldo posted on Tuesday, February 19, 2008

I've been working with Unit Testing that's available in VS-2008 Pro now. In the Project Tracker library, Project.vb Exists function. I keep getting data portal errors.

Protected Overrides Sub DataPortal_Execute()

Using cn As New SqlConnection(Database.PTrackerConnection)

cn.Open()

Using cm As SqlCommand = cn.CreateCommand

cm.CommandType = CommandType.Text

cm.CommandText = "SELECT Id FROM Projects WHERE Id=@id"

cm.Parameters.AddWithValue("@id", mId)

Dim count As Integer = CInt(cm.ExecuteScalar)

mExists = (count > 0)

End Using

End Using

End Sub

I believe the Sql should be:

"SELECT COUNT(Id) FROM Projects WHERE Id=@id"

This is in Visual Basic  version 3.0.3-071127

I love this framework by the way and looking forward to the VB version of your 3.5 version book. That will be out before the C# version, right? Big Smile [:D]

Burl

 

RockfordLhotka replied on Wednesday, February 20, 2008

Huh... Actually, it should use the stored procedure:

cm.CommandType = CommandType.StoredProcedure
cm.CommandText =
"existsProject"
cm.Parameters.AddWithValue("@id", mId)
Dim count As Integer = CInt(cm.ExecuteScalar)

 

Copyright (c) Marimer LLC