Exchange data between forms : Const Expression is req.
This is a little complicated so I will try and be clear as possible. I have two forms. The first form has a drop down box that lists all the table names in my database.
The second form opens a editable datagrid for the user to make changes to the table.
I am able to grab the table name from the first form and pass it to the second form with this.
Code:
' This is code from the first form. The table
' name is selected from a combobox in this
' form and then passed to the second form
Public Property getTableName()
Get
Return cboChooseTable.Text
End Get
Set(ByVal Value)
cboChooseTable.Text = Value
End Set
End Property
---------------------------------------------------
Private Sub lnkOpenTable_LinkClicked _
(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
Handles lnkOpenTable.LinkClicked
' The value is passed to the second
' form named frmSqlEditor here.
Dim frm1 As New frmSqlEditor
frm1.strTableName = getTableName
PandRControl(frm1, lnkOpenTable)
End Sub
Now on the second form (frmSqlEditor) this is where I am having problems. I am trying to get the table name into the constants at the top of the code like this.
Code:
Public Shared strTableName As String
Private Const Select_String As String = _
"Select * From " &t strTableName
Private Const Connect_String As String = ( _
"Data Source=ra04;" & _
"Initial Catalog=Viewpoint;" & _
"User ID=User;password=Password")
Private m_DataSet As DataSet
The strTableName has the blue squiggly under it with the message Constant Expression is required. How do I correct this? By the way the correct table name is making it from form to form because I can send it to the screen using a msgbox function.