chrisryhal
asked on
SQL Connection Question
I am new here, so please bare with me. I understand what is going on in the code below. My problem, is how do I or WHERE do I set the connection to SQL, as far as my Server and such? This is an example from Microsoft. I am so used to hard coding the information as in VB6, and getting used to this new stuff now. This is to fill a datagrid
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New SqlConnection(System.Confi guration.C onfigurati onSettings .AppSettin gs("Benchm arkingStri ng"))
MyCommand = New SqlDataAdapter("select * from Benchmarking", MyConnection)
DS = New DataSet
MyCommand.Fill(DS, "Authors")
BenchmarkingDataGrid.DataS ource = DS.Tables("Benchmarking"). DefaultVie w
BenchmarkingDataGrid.DataB ind()
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New SqlConnection(System.Confi
MyCommand = New SqlDataAdapter("select * from Benchmarking", MyConnection)
DS = New DataSet
MyCommand.Fill(DS, "Authors")
BenchmarkingDataGrid.DataS
BenchmarkingDataGrid.DataB
End Sub
ASKER
Actually, there is nothing in the Web.Config like that. Could you please show me a full example, with a fake connection string to a server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is great!!! See, I learn something new everyday. So now, if I ever want to reference that connection string, I can just call upon my AppSettings. Thanks a million
CR
CR
<appSettings>
<add key="BenchmarkingString" value="here is the connection string"/>
</appSettings>