swine Posted October 9, 2012 Share Posted October 9, 2012 (edited) Hey there, I've already spent one day on this problem and still don't know what's wrong. I have a stored procedure giving me some project details. I want to save them into a list. So I created a project class.Using the SqlDataReader, I instantiate the project and put them in the list. Everything works fine, except one datafield. The values are always 0. But if I check the SQL, I'm getting the correct values. I really don't know, why this is happening. Dim cmd As New SqlCommandcmd.CommandText = "sao.GetProjects"cmd.CommandType = CommandType.StoredProcedurecmd.Connection = New SqlConnection(GetConnectionString)Using cmd.Connection Using cmd Dim projects As New List(Of clsProject) cmd.Connection.Open() Dim reader As SqlDataReader = cmd.ExecuteReader While reader.Read Dim project As New clsProjekt 'This is the field project.employeeNo = reader("employeeNo") 'Always get Empty If project.employeeNo = 0 Then Debug.Print("Empty") Else Debug.Print(project.employeeNo) End If project.orderNo = reader("OrderNo") project.description = reader("Description") project.customer = reader("Customer") projects.Add(project) End While End UsingEnd Using Thanks for helping Edited October 9, 2012 by swine Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now