T
Tmuld
Hello,
I have designed a simple web page that takes input from a user(from a
textbox), then searches for that input in a database, when the Search
button is clicked. Assuming the connection is good - help with the
error, please?
Sqlconnection1 was dragged and dropped on the the design window and the
connection was accepted. I assume I can use that instead of manually
typing out a whole connection string - right? (instead of having to
type in ConnStr="data source=IP"&"database=DB;.....")
Here is the code:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
Dim ConnStr As New SqlConnection
ConnStr = SqlConnection1
Dim SQL As String
ConnStr.Open()
Try
SQL = "select * from Database WHERE SearchCol LIKE %' " &
Search.Text & "'"
Dim MySqlCmd As New SqlCommand(SQL, ConnStr)
Dim Reader As SqlDataReader
Reader = MySqlCmd.ExecuteReader
myDatagrid.DataSource = Reader
Finally
ConnStr.Close()
End Try
End Sub
1) There is not option for my Datagrid to bind (no
myDatagrid.Databind() option in the drop downs - why not? After the
myDatagrid.Datasource there should be the bind - right?
2)This error appears at the ConnStr.Open() line:
An unhandled exception of type 'System.Data.SqlClient.SqlException'
occurred in system.data.dll
Additional information: System error.
3) [bonus] Note, the connection always asks me for a password - user
name and password, when I try to make a new connection or refresh data
(via the server tools in VS). How do I make it trusted. The DB (sql
server)ir running on a remote machine.
Suggestions?
Using Visual Studio 2003.
Many Thanks!
Tmuld
I have designed a simple web page that takes input from a user(from a
textbox), then searches for that input in a database, when the Search
button is clicked. Assuming the connection is good - help with the
error, please?
Sqlconnection1 was dragged and dropped on the the design window and the
connection was accepted. I assume I can use that instead of manually
typing out a whole connection string - right? (instead of having to
type in ConnStr="data source=IP"&"database=DB;.....")
Here is the code:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
Dim ConnStr As New SqlConnection
ConnStr = SqlConnection1
Dim SQL As String
ConnStr.Open()
Try
SQL = "select * from Database WHERE SearchCol LIKE %' " &
Search.Text & "'"
Dim MySqlCmd As New SqlCommand(SQL, ConnStr)
Dim Reader As SqlDataReader
Reader = MySqlCmd.ExecuteReader
myDatagrid.DataSource = Reader
Finally
ConnStr.Close()
End Try
End Sub
1) There is not option for my Datagrid to bind (no
myDatagrid.Databind() option in the drop downs - why not? After the
myDatagrid.Datasource there should be the bind - right?
2)This error appears at the ConnStr.Open() line:
An unhandled exception of type 'System.Data.SqlClient.SqlException'
occurred in system.data.dll
Additional information: System error.
3) [bonus] Note, the connection always asks me for a password - user
name and password, when I try to make a new connection or refresh data
(via the server tools in VS). How do I make it trusted. The DB (sql
server)ir running on a remote machine.
Suggestions?
Using Visual Studio 2003.
Many Thanks!
Tmuld