D
David Lozzi
Here is the proc:
CREATE PROCEDURE [dbo].[sp_CheckNetName]
@CID as int,
@Netname as nvarchar(25),
@Return as int OUTPUT
AS
IF EXISTS (SELECT DISTINCT netname FROM computers WHERE CompanyID = @CID AND UPPER(netname) = UPPER(@Netname))
SELECT @Return = 1
ELSE
SELECT @Return = 0
GO
Which this works great in query analyzer.... Now here is the ASP.NET script to load this proc:
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyDataAdapter As SqlDataAdapter
MyConnection = New SqlConnection(sqlconn)
MyDataAdapter = New SqlDataAdapter("sp_CheckNetName", MyConnection)
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CID", SqlDbType.int, 4))
MyDataAdapter.SelectCommand.Parameters("@CID").Value = Trim(request("COMPID"))
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Netname", SqlDbType.VarChar, 25))
MyDataAdapter.SelectCommand.Parameters("@Netname").Value = Trim(netname.text)
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Return", SqlDbType.Int, 4))
MyDataAdapter.SelectCommand.Parameters("@Return").Direction = ParameterDirection.Output
DS = New DataSet()
MyDataAdapter.Fill(DS, "Net")
results.Text = MyDataAdapter.SelectCommand.Parameters(2).Value
MyDataAdapter.Dispose()
MyConnection.Close()
The results always displays 0, however in queryanalyzer, it will display the appropriate response.
Thanks!
CREATE PROCEDURE [dbo].[sp_CheckNetName]
@CID as int,
@Netname as nvarchar(25),
@Return as int OUTPUT
AS
IF EXISTS (SELECT DISTINCT netname FROM computers WHERE CompanyID = @CID AND UPPER(netname) = UPPER(@Netname))
SELECT @Return = 1
ELSE
SELECT @Return = 0
GO
Which this works great in query analyzer.... Now here is the ASP.NET script to load this proc:
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyDataAdapter As SqlDataAdapter
MyConnection = New SqlConnection(sqlconn)
MyDataAdapter = New SqlDataAdapter("sp_CheckNetName", MyConnection)
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CID", SqlDbType.int, 4))
MyDataAdapter.SelectCommand.Parameters("@CID").Value = Trim(request("COMPID"))
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Netname", SqlDbType.VarChar, 25))
MyDataAdapter.SelectCommand.Parameters("@Netname").Value = Trim(netname.text)
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Return", SqlDbType.Int, 4))
MyDataAdapter.SelectCommand.Parameters("@Return").Direction = ParameterDirection.Output
DS = New DataSet()
MyDataAdapter.Fill(DS, "Net")
results.Text = MyDataAdapter.SelectCommand.Parameters(2).Value
MyDataAdapter.Dispose()
MyConnection.Close()
The results always displays 0, however in queryanalyzer, it will display the appropriate response.
Thanks!