Private ComputerName As String = System.Net.Dns.GetHostName
Private DatabaseName As String = "praise.dbo.praise" 'Change Mapia to your database name
Private ConnectionString As String = "Data Source=ADMINROAM\SQLEXPRESS;Initial Catalog=praise;Integrated Security=True"
Private conn As New SqlConnection
Public Function GetData(ByVal strSQL1 As String) As DataSet
Dim ds As New DataSet
Try
If conn.State = ConnectionState.Open Then
conn.Close()
End If
conn.ConnectionString = ConnectionString
conn.Open()
' Create a data adapter
Dim da As New SqlDataAdapter(strSQL1, conn)
' Create DataSet, fill it and view in data grid
da.Fill(ds, "praise.dbo.praise")
Catch ex As Exception
End Try
Return ds
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' If ComboBox1.Text = "Search By..." Then
' MsgBox("Please select a Search By... option.")
' End If
' If TextBox1.Text = "Search For..." Then
' MsgBox("Please select a Keyword to search.")
' ElseIf TextBox1.Text = "" Then
' MsgBox("Please select a Keyword to search.")
' End If
Dim ds_Search As DataSet
ds_Search = GetData("select * from praise.dbo.praise where " & ComboBox1.Text & " = '" & TextBox1.Text & "'")
SearchForm.Show()
SearchForm.DataGridView1.DataSource = ds_Search.Tables(0)
End Sub
Public Class SearchForm
Private Sub SearchForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ModelDataSet.Praise' table. You can move, or remove it, as needed.
Me.PraiseTableAdapter.Fill(Me.ModelDataSet.Praise)
End Sub
Private Sub RichTextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
end class