 |
| VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 14th, 2006, 04:22 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
eh.. i get out of ideas here.. i always get results with executescalar... what if you take out the convert???
HTH
Gonzalo
|
|

November 14th, 2006, 04:27 PM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No results. It must be something in the stored proc. I am running out of ideas also.
|
|

November 14th, 2006, 04:30 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
ok.. last idea..
let's try writting another SP.. can you??
Code:
CREATE PROCEDURE dbo.testprocedure
(@DisplayValue NVARCHAR(50))
AS
SET NOCOUNT ON
SELECT U.FullName FROM DropDownData D, Users U WHERE D.DropDownCategory = 'Level5' AND D.DisplayValue=@DisplayValue and D.Misc1 = U.Associate_ID
GO
can you try with that???
also in the code you will have 1 extra parameter (comment it)... and see if you get a result with executescalar.
HTH
Gonzalo
|
|

November 14th, 2006, 04:38 PM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I copied and pasted your code (I hope you don't mind) into a new procedure and I still get no results in the label I am trying to populate.
|
|

November 14th, 2006, 04:42 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
no problem.. can you trace the code?? do you get to the line that fill the label or are you getting out with an error?????
(try this in the catch)
Code:
lblLevel5Manager.Text = ex.Message
HTH
Gonzalo
|
|

November 15th, 2006, 08:56 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am getting to the line with the textbox in it and when I tried the "lblLevel5Manager.text = ex.Message" it produced nothing either. Should I put the old proc back into play or keep the one that you gave me?
|
|

November 15th, 2006, 10:08 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
do you get an error?? or you paste the code i gave you in the wrong place?? can you paste the function here like you have it now??
we will get to the bottom of it...
HTH
Gonzalo
|
|

November 15th, 2006, 10:16 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is the function:
Code:
Public Function GetLevel5Manager(ByVal strCriteria As String) As DataTable
Try
Dim strConn As String = HttpContext.Current.Session("ConnStr")
Dim conn As New SqlConnection(strConn)
Dim cmd As SqlCommand
Dim strCrit As String = Mid(strCriteria, 10, 8)
conn.Open()
cmd = conn.CreateCommand()
With cmd
.CommandText = "sp_PopulateLevel5Manager"
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@DisplayValue", SqlDbType.NVarChar, 50)
.Parameters.Add("@Lvl5Mgr", SqlDbType.NVarChar, 50)
.Parameters("@DisplayValue").Value = strCrit
.Parameters("@DisplayValue").Direction = ParameterDirection.Input
.Parameters("@Lvl5Mgr").Direction = ParameterDirection.ReturnValue
End With
Dim dtLvl5Mgrs As New DataTable
Dim da As New SqlDataAdapter
da = New SqlDataAdapter(cmd)
da.Fill(dtLvl5Mgrs)
'nullcuteScalar()
'lblLevel5Manager.Text = Convert.ToString(@Lvl5Mgr)
'lblLevel5Manager.Text = Convert.ToString(cmd.Parameters("@Lvl5Mgr").Value)
lblLevel5Manager.Text = nullcuteScalar
'Return dtLvl5Mgrs
conn.Close()
Catch ex As Exception
Dim sTemp As String
sTemp = ex.Message
End Try
End Function
The stored procedure is the same one that you gave me
|
|

November 15th, 2006, 10:33 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I don't know if this is of any help but if I change the executescalar to ExecuteNonQuery I get a result of -1. Still not the result I want but it is a result.
|
|

November 15th, 2006, 10:42 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
ok.. let's try something.. maybe i'm not explaining ok...
i want you to try this function with the SP i gave to you...
Code:
Public sub GetLevel5Manager(ByVal strCriteria As String)
Try
Dim strConn As String = HttpContext.Current.Session("ConnStr")
Dim conn As New SqlConnection(strConn)
Dim cmd As SqlCommand
'when you trace the code be sure that this string has the rigth data and please try it in the SP alone to see if you get results
Dim strCrit As String = Mid(strCriteria, 10, 8)
conn.Open()
cmd = conn.CreateCommand()
With cmd
.CommandText = "testprocedure" 'the one i gave you
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@DisplayValue", SqlDbType.NVarChar, 50)
.Parameters("@DisplayValue").Value = strCrit
End With
lblLevel5Manager.Text = executeScalar
conn.Close()
Catch ex As Exception
lblLevel5Manager.Text= ex.Message
End Try
End sub
try this function.. if it still returns nothing then the parameter you are passing to the SP is bad and that's why you are not receiving any result. this should give to you the data or an exception...
HTH
Gonzalo
|
|
 |