Scott Marcus
marcus at tsstech.com
Wed Aug 24 11:03:44 CDT 2005
John, Try opening the connection earlier in the code. Scott Marcus IT Programmer TSS Technologies Inc. www.tss.com -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of John W. Colby Sent: Wednesday, August 24, 2005 11:53 AM To: dba-vb at databaseadvisors.com Subject: RE: [dba-VB] RSS Feed database I get a record back. Now... The code in the VB.Net program looks like: Imports System Imports System.Data Imports System.Data.SqlClient Namespace RSS_Feed ' <summary> ' This class holds all of the data data defines an RSS Feed Source. ' The RSS Feed Source data comes from the WebNewsSource table ' </summary> Public Class RSSItem Private id As Integer Public Sub New(ID As Integer) ' Set the id id = ID ' Fill the data FillMe() End Sub 'New Private Sub FillMe() Dim strSQLCnn As String Try 'strSQLCnn = System.Configuration.ConfigurationSettings.AppSettings("ConnectString") strSQLCnn = "server=colbyM6805;uid=sa; password=;database=master" ' Set up the connection 'Dim objConnection As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("Co nnec tString")) Dim objConnection As New SqlConnection(strSQLCnn) ' Create a data table Dim dt As New DataTable("RSS") ' Set up the command Dim objCommand As New SqlCommand("upWebNewsSource_SelectOne", objConnection) objCommand.CommandType = CommandType.StoredProcedure ' Set up SP parameters objCommand.Parameters.Add("@ID", SqlDbType.Int).Value = id ' Open the connection and fill that datatable objConnection.Open() Dim da As New SqlDataAdapter(objCommand) da.Fill(dt) ' close the connection objConnection.Close() ' We will use the first row ( We will only have one row) Dim dr As DataRow = dt.Rows(0) 'Dim dr As DataRow = dt.Rows(1) ' Set the class's Properties [Select] = dr("RSSSelect").ToString() Title = dr("RSSTitle").ToString() Link = dr("RSSLink").ToString() Description = dr("RSSDescription").ToString() URL = dr("RSSURL").ToString() Catch ex As Exception MessageBox.Show("ERROR:" + ex.Message.ToString()) Console.WriteLine(("ERROR:" + ex.Message.ToString())) End Try End Sub 'FillMe End Class 'RSSItem End Namespace 'RSS_Feed ' You can see where I had to hard code the connection string because I couldn't get the configuration setting file to load. No problem there, it at least works. I had a bit of an issue getting logged in until I set "Windows and SQL Server Login". Now that issue went away. However I get an error on: Dim dr As DataRow = dt.Rows(0) The error is that there is no record at position 0 indicating that for some reason the SP is not returning data. That is the first error encountered however so I'm a bit baffled. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia Sent: Wednesday, August 24, 2005 11:41 AM To: dba-vb at databaseadvisors.com Subject: Re: [dba-VB] RSS Feed database If you go to your QA window and type in EXEC upWebNewsSource_SelectOne 1 or a valid ID, what is the resultset? On 8/24/05, Scott Marcus <marcus at tsstech.com> wrote: > > I'm just shooting int the dark... How about parenths around the @ID > int > > Scott Marcus > IT Programmer > TSS Technologies Inc. > www.tss.com <http://www.tss.com> > > > -----Original Message----- > From: dba-vb-bounces at databaseadvisors.com > [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of John W. > Colby > Sent: Wednesday, August 24, 2005 11:15 AM > To: dba-vb at databaseadvisors.com > Subject: [dba-VB] RSS Feed database > > Do I have no takers helping me get this thing working? The end result > will be a system for logging an RSS feed into data tables for analysis > or use. > Could be niiiice. ;-) > > I have made good progress, I have a database set up in SQL Server > specifically for this project. I have the tables built per the script > included in the C# zip. There are two records in the WebNewsSource > table. I am logging in to the database. The issue at this point is > that the SP that is supposed to return the rows in the database > apparently doesn't. > > The SP looks like: > > ---------------------------------------------------------------------- > -- > ---- > ----- > -- Stored procedure that will select an existing row from the table > 'WebNewsSource' > -- based on the Primary Key. > -- Gets: @ID int > ------------------------------------------------------------------------ > ---- > ----- > CREATE PROCEDURE [dbo].[upWebNewsSource_SelectOne] > @ID int > AS > SET NOCOUNT ON > -- SELECT an existing row from the table. > SELECT > [ID], > [Source], > [RSSURL], > [RSSSelect], > [RSSTitle], > [RSSLink], > [RSSDescription] > FROM [dbo].[WebNewsSource] > WHERE > [ID] = @ID > > > GO > > How do I go about just running the SP passing in an ID and viewing the > results? > > John W. Colby > www.ColbyConsulting.com <http://www.ColbyConsulting.com> > > Contribute your unused CPU cycles to a good cause: > http://folding.stanford.edu/ > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com