1 Replies - 2424 Views - Last Post: 11 October 2012 - 08:24 AM Rate Topic: -----

#1 wanabavbcoder  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 48
  • Joined: 08-October 12

DataReader is unable to show all the values

Posted 10 October 2012 - 03:24 AM

Okay so i have a stored procedure in sql which looks like:
CREATE  proc valida 
@Venue_Name char(30),@Start_Date nvarchar(8),@End_Date nvarchar(8),@Venue_Rent int output
as 
select a.Venue_Name,a.Start_Date,a.End_Date,b.Venue_Rent from Upcoming_event a, Venue_Details b 
where a.Venue_Name = @Venue_Name and
b.Venue_Name = @Venue_Name and
Start_Date = @Start_Date and
End_Date = @End_Date and
Venue_Rent = @Venue_Rent



which has been successfully created.
So i try to use a datareader to display the three things but fails and moves on to the next statement
cperson = TextBox1.Text
        phone = Val(TextBox2.Text)
        company = TextBox3.Text
        address = TextBox4.Text
        noatt = Val(TextBox5.Text)
        costatt = Val(TextBox6.Text)
        cat = ComboBox1.Text
        dae1 = DateTimePicker1.Format = DateTimePickerFormat.Custom
        DateTimePicker1.CustomFormat = "dd,MM,yy"
        DateTimePicker1.Format = DateTimePickerFormat.Custom
        dae2 = DateTimePicker2.Format = DateTimePickerFormat.Custom
        DateTimePicker2.CustomFormat = "dd,MM,yy"
        DateTimePicker2.Format = DateTimePickerFormat.Custom
        Dim connetionString As String
        Dim connection As SqlConnection
        connetionString = "workstation id=RIKESH;packet size=4096;user id=sa;data source=RIKESH;persist security info=False;initial catalog=Merrymeetings"
        connection = New SqlConnection(connetionString)
        Dim sqlComm As New SqlCommand
        Dim reader As SqlDataReader
        sqlComm.Connection = connection
        connection.Open()
        sqlComm.CommandType = CommandType.StoredProcedure
        sqlComm.CommandText = "valida"
        sqlComm.Parameters.Add("@Venue_Name", SqlDbType.Char, 30).Value = ComboBox2.Text
        sqlComm.Parameters("@Venue_Name").Direction = ParameterDirection.Input
        sqlComm.Parameters.Add("@Start_Date", SqlDbType.NVarChar, 8).Value = DateTimePicker1.Text
        sqlComm.Parameters("@Start_Date").Direction = ParameterDirection.Input
        sqlComm.Parameters.Add("@End_Date", SqlDbType.NVarChar, 8).Value = DateTimePicker2.Text
        sqlComm.Parameters("@End_Date").Direction = ParameterDirection.Input
        sqlComm.Parameters.Add("@Venue_Rent", SqlDbType.NVarChar, 8)
        sqlComm.Parameters("@Venue_Rent").Direction = ParameterDirection.Output


        Try
            reader = sqlComm.ExecuteReader()
            If reader.Read Then
   [color="#FF0000"]Skips this part[/color]             MessageBox.Show(reader.Item(0) & " is booked  from:" & reader.Item(1) & "Till-" & reader.Item(2) & "Rent" & reader.Item(3), "WHOOPS", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Button1.Hide()
            ElseIf MessageBox.Show("Venue is available", "HOORAY!!!", MessageBoxButtons.OK, MessageBoxIcon.Information) Then
                Button1.Show()

            End If
        Catch sqlex As SqlException
            MessageBox.Show(sqlex.Message)
        End Try
        connection.Close()

I have come to a realization that a datareader and I are not friends

This post has been edited by modi123_1: 10 October 2012 - 07:05 AM
Reason for edit:: highlight the text and just click the 'code' button in the text editor


Is This A Good Question/Topic? 0
  • +

Replies To: DataReader is unable to show all the values

#2 zeeshanef  Icon User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 76
  • Joined: 14-April 12

Re: DataReader is unable to show all the values

Posted 11 October 2012 - 08:24 AM

Why did you use @Venue_Rent as Output parameter?
In your SP you are not selecting any value in this parameter and using it like input parameter:
Venue_Rent = @Venue_Rent

But if it is really output parameter then you should store any value for output. like this:
Select  @Venue_Rent = Venue_Rent

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1