5 Replies - 521 Views - Last Post: 09 October 2012 - 10:08 AM Rate Topic: -----

#1 wanabavbcoder  Icon User is offline

  • New D.I.C Head

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

Can a value from sql be passed to a label on another form?

Posted 09 October 2012 - 12:45 AM

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 = "valid"
        sqlComm.Parameters.Add("@Venue_Name", SqlDbType.Char, 30).Value = ComboBox2.Text
        sqlComm.Parameters("@Venue_Name").Direction = ParameterDirection.Input


Can the variable "@Venue_Name" be passed to a label in another form in the same project???
If so, How do does one do that?

Is This A Good Question/Topic? 0
  • +

Replies To: Can a value from sql be passed to a label on another form?

#2 wanabavbcoder  Icon User is offline

  • New D.I.C Head

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

Re: Can a value from sql be passed to a label on another form?

Posted 09 October 2012 - 01:04 AM

Is this even possible? Or maybe i am asking for a miracle. :helpsmilie: :death:
Was This Post Helpful? 0
  • +
  • -

#3 wanabavbcoder  Icon User is offline

  • New D.I.C Head

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

Re: Can a value from sql be passed to a label on another form?

Posted 09 October 2012 - 02:19 AM

 Try

            reader = sqlComm.ExecuteReader()
            If reader.Read Then
                MessageBox.Show(reader.Item(0) & " is booked  from:" & reader.Item(1) & " Till-" & reader.Item(2), "WHOOPS!!!", MessageBoxButtons.OK, MessageBoxIcon.Information)
               ERROR IS HERE---> reader.Item(0) = cal.Label5.ToString
            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


So what do I do to fix this error?
Can Someone assist me?

The error reads : Property'item' is 'ReadOnly'
Was This Post Helpful? 0
  • +
  • -

#4 manos364  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 42
  • Joined: 09-October 12

Re: Can a value from sql be passed to a label on another form?

Posted 09 October 2012 - 03:42 AM

In order to pass parameters between forms you need to declare a string to the form you want to pass the parameter.
Public Shared passParameter As String

And then to pass the parameter to the form you need this code to the form that is going to send the parameter.
targetForm.passParameter = "parameter to pass"

Was This Post Helpful? 0
  • +
  • -

#5 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3718
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: Can a value from sql be passed to a label on another form?

Posted 09 October 2012 - 04:08 AM

Duplicate threads merged. Do not double post your questions!
Was This Post Helpful? 0
  • +
  • -

#6 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2262
  • View blog
  • Posts: 9,464
  • Joined: 29-May 08

Re: Can a value from sql be passed to a label on another form?

Posted 09 October 2012 - 10:08 AM

View Postmanos364, on 09 October 2012 - 11:42 AM, said:

In order to pass parameters between forms you need to declare a string to the form you want to pass the parameter.
Public Shared passParameter As String

And then to pass the parameter to the form you need this code to the form that is going to send the parameter.
targetForm.passParameter = "parameter to pass"


Not a good idea / approach. Shared means its available to all instances.
Pass the parameters in via constructor, properties or even better an events.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1