Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/03/2006, 04:34
txol
 
Fecha de Ingreso: marzo-2006
Mensajes: 1
Antigüedad: 18 años, 1 mes
Puntos: 0
conexion con sql server 2000

Hola,
tengo el siguiente codigo para conectarme con una base de datos:
<%@ Page Language="VB" ContentType="text/html" Debug="true" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<html>

<script language="VB" runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)

Dim MyConnection As SqlConnection = New SqlConnection("server=localhost;database=pubs;Trus ted_Connection=yes")
Dim MyCommand As SqlCommand = New SqlCommand("select * from Authors", MyConnection)

MyConnection.Open()

Dim dr As SqlDataReader = MyCommand.ExecuteReader()

MyDataGrid.DataSource = dr
MyDataGrid.DataBind()

MyConnection.Close()
End Sub

</script>

<body>

<h3><font face="Verdana">Selección simple del control DataGrid</font></h3>

<ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>

</body>
</html>

pero me da un erro en la linea MyConnection.Open().

pone lo siguiente:SQL Server does not exist or access denied.

ruego que me contesteis si podeis ayudarme.

muchas gracias