Wrox Programmer Forums
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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
Old June 2nd, 2007, 02:52 PM
Friend of Wrox
Join Date: May 2005
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default stored procedure problem

I have this code

 Dim cnn As New SqlClient.SqlConnection(strConnection)
            Dim Cmd As New SqlCommand()
            Cmd.Connection = cnn
            With Cmd
                .Connection = cnn
                .CommandType = CommandType.StoredProcedure
                .CommandText = "K1SP_Stats"
            End With

            With Cmd.Parameters

                Dim strURL As Uri = Request.Url

                Cmd.Parameters.Add("@pageName", SqlDbType.NVarChar, 100)
                Cmd.Parameters("@pageName").Value = strURL

                Cmd.Parameters.Add("@DateTime", SqlDbType.SmallDateTime)
                Cmd.Parameters("@DateTime").Value = Today.Date()

                Cmd.Parameters.Add("@UserHost", SqlDbType.VarChar, 100)
                Cmd.Parameters("@UserHost").Value = Request.UserHostAddress

                Cmd.Parameters.Add("@UserAgent", SqlDbType.VarChar, 100)
                Cmd.Parameters("@UserAgent").Value = Request.UserAgent

                Cmd.Parameters.Add("@Referrer", SqlDbType.NText)
                Cmd.Parameters("@Referrer").Value = Request.UrlReferrer

            End With



i get this error when request.url or request.referrer is null

Object must implement IConvertible

my stored proc:

  @pageName nvarchar(100) = NULL,
  @DateTime smallDateTime = NULL,
  @UserHost varchar(100)= Null,
  @UserAgent varchar(100)= Null,
  @referrer ntext
  Insert into k1_pageViews (PageName,Date_Time,UserHost,UserAgent,Referrer) values ( @pageName,@DateTime,@UserHost,@UserAgent,@Referrer )


Old June 3rd, 2007, 12:31 AM
Friend of Wrox
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts

I really can't understand your problem.. but i suggest that u convert your null values to empty strings.. just to make sure.

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
Old June 3rd, 2007, 09:27 PM
planoie's Avatar
Friend of Wrox
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

Not really a solution to your particular problem but...

It looks like you are logging request information. You can configure IIS to log to a SQL server database. All this information (plus a whole lot more) would be automatically collected for you.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with stored procedure analuz ADO.NET 1 July 18th, 2007 08:33 AM
Stored procedure problem akumarp2p Reporting Services 1 May 29th, 2007 01:25 AM
Stored Procedure Problem kwilliams SQL Server 2000 7 June 23rd, 2006 03:03 PM
Stored procedure problem dkspivey SQL Language 2 February 6th, 2006 01:44 PM
Stored Procedure Problem brettdavis4 ASP.NET 1.0 and 1.1 Basics 7 November 3rd, 2003 09:46 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.