Im using Microsoft Visual Basic.net 2003.
my problem is that Im trying to retrieve database data using .net for the first time.
I've created a new webform and added the following code:
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
'1. Create a connection
Dim myConnection as New SqlConnection("HERE")
'2. Create the command object, passing in the SQL string
Dim myCommand as New SqlCommand("SELECT * FROM ADMIN", myConnection)
'Set the datagrid's datasource to the datareader and databind
dgPopularFAQs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
<asp:datagrid id="test" runat="server" />
My problem is that I dont know how to create the connection string or bind it to the test id. So within the environment I've gone Tools - Connect to Database - I've selected the right database, username etc.. so now within the environment I get a panel titled data connections with all my tables from the database. Looking at the properties it does mention the connection string. copying and pasting this into the connectstring bit above, denoted with 'HERE' it doesnt work.
please advise, many thanks