Salve a tutti ragazzi ho un problema con la mia prima pagina asp.net ho creato un nuovo progetto Sito Web in cui all'interno carico in un gridview i dati provenienti da un database access (residente sul pc) attraverso odbc. Di seguito vi posto il codice
Questo è il codice contenuto nel file ASPX
<%
@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%
@ Import Namespace="System.Data" %>
<%
@ Import Namespace ="System.Data.Odbc" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Aps.NEY Prime Armititle>
head>
<
body>
<form id="form1" runat="server">
<div style="text-align: center">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="14pt" Height="32px"
Text="Asp.NET Prime Armi Test" Width="752px">asp:Label><br />
<br />
<br />
div>
<div style="text-align: justify ">
<br />
<br />
<asp:DropDownList ID="DropDownList1" runat="server" Width="192px">
asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server">asp:TextBox><br />
<asp:RequiredFieldValidator id="ControlloTesto" runat="server" controltovalidate="Textbox1" ErrorMessage="Campo Obbligatorio" />
<div style="text-align :right">
<asp:Label ID="Label2" runat="server" Text="Label" Width="336px">asp:Label><br />
div>
div>
<div style="text-align: justify ">
<asp:Button ID="Button1" runat="server" Text="Bottone DropDown"
Width="192px" />
<br />
<br />
<br />
<br />
<asp:DropDownList ID="DropDownList2" runat="server" Width="192px">
asp:DropDownList>
<asp:TextBox ID="TextBox2" runat="server">asp:TextBox>
<asp:Button ID="btn_Filtro" runat="server" Text="Filtra" Width="112px" />
<asp:Button ID="btn_Reset" runat="server" Text="Reset" Width="120px" /><br />
<br />
<asp:GridView ID="GridView1" runat="server">
asp:GridView>
div>
form>
body>
html>
Mentre questo è il codice scritto nel file VB
Imports
ASP.default_aspx
Imports
Microsoft.SqlServer.Server
Imports
System.Data
Partial
Class _Default
Inherits System.Web.UI.Page
Dim dt As New DataTable("Tabella")
Dim dv As New DataView
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
DropDownList1.Items.Add(
"Test1")
DropDownList1.Items.Add(
"Test2")
DropDownList1.Items.Add(
"Test3")
DropDownList1.Items.Add(
"Test4")
DropDownList1.Items.Add(
"Test5")
DropDownList1.Items.Add(
"Test6")
DropDownList2.Items.Add(
"MATRIC")
DropDownList2.Items.Add(
"COGNOME")
DropDownList2.Items.Add(
"NOME")
DropDownList2.Items.Add(
"DANASC")
DropDownList2.Items.Add(
"INDIR_P")
DropDownList2.Items.Add(
"CITTA_P")
DropDownList2.Items.Add(
"PROV_P")
DropDownList2.Items.Add(
"CAP_P")
CaricaDati(
"dsn=pimm_master")
dv.Table = dt
GridView1.DataSource = dv
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Label2.Text =
"E' stato scritto il testo: " + TextBox1.Text + " ed Š stato scelto il il valore: " + DropDownList1.SelectedItem.Text
End Sub
Private Sub CaricaDati(ByVal Connectionstring As String)
dt =
New DataTable("Tabella")
Dim Query As String = "SELECT DIPENDENTI.MATRIC, DIPENDENTI.COGNOME, DIPENDENTI.NOME, DIPENDENTI.DANASC, DIPENDENTI.INDIR_P, DIPENDENTI.CITTA_P, DIPENDENTI.PROV_P, DIPENDENTI.CAP_P FROM DIPENDENTI;"
Dim command As New Odbc.OdbcCommand(Query)
Using connection As New Odbc.OdbcConnection(Connectionstring)
command.Connection = connection
connection.Open()
Dim reader As Odbc.OdbcDataReader = command.ExecuteReader
dt.Load(reader)
reader.Close()
connection.Close()
End Using
End Sub
End
Class
mentre questo è il codice scritto nel file WebConfig
xml version="1.0"?>
<
configuration>
<
appSettings/>
<
connectionStrings/>
<
system.web>
<
identity impersonate="true" />
<
compilation debug="true" strict="false" explicit="true"/>
<
pages>
<
namespaces>
<
clear/>
<
add namespace="System"/>
<
add namespace ="System.Data"/>
<
add namespace ="System.Data.Odbc"/>
<
add namespace="System.Collections"/>
<
add namespace="System.Collections.Specialized"/>
<
add namespace="System.Configuration"/>
<
add namespace="System.Text"/>
<
add namespace="System.Text.RegularExpressions"/>
<
add namespace="System.Web"/>
<
add namespace="System.Web.Caching"/>
<
add namespace="System.Web.SessionState"/>
<
add namespace="System.Web.Security"/>
<
add namespace="System.Web.Profile"/>
<
add namespace="System.Web.UI"/>
<
add namespace="System.Web.UI.WebControls"/>
<
add namespace="System.Web.UI.WebControls.WebParts"/>
<
add namespace="System.Web.UI.HtmlControls"/>
namespaces>
pages>
<
authentication mode="Windows"/>
system.web>
configuration>
Però il mio problema è che quando vado ad aprire il sito attraverso il browser mi mostra questo messaggio che non riesco a capire
Errore server nell'applicazione '/AspNET_Test'.
ERROR [HY000] [Microsoft][Driver ODBC Microsoft Access] Errore di rete o disco.
ERROR [IM006] [Microsoft][Driver Manager ODBC] Funzione SQLSetConnectAttr del driver non riuscita.
ERROR [HY000] [Microsoft][Driver ODBC Microsoft Access] Errore di rete o disco.
Descrizione: Eccezione non gestita durante l'esecuzione della richiesta Web corrente. Per ulteriori informazioni sull'errore e sul suo punto di origine nel codice, vedere l'analisi dello stack.
Dettagli eccezione: System.Data.Odbc.OdbcException: ERROR [HY000] [Microsoft][Driver ODBC Microsoft Access] Errore di rete o disco.
ERROR [IM006] [Microsoft][Driver Manager ODBC] Funzione SQLSetConnectAttr del driver non riuscita.
ERROR [HY000] [Microsoft][Driver ODBC Microsoft Access] Errore di rete o disco.
Errore nel codice sorgente:
<PRE style="FONT-SIZE: 0.9em; FONT-FAMILY: 'Lucida Console'">Riga 44: Using connection As New Odbc.OdbcConnection(Connectionstring)
Riga 45: command.Connection = connection
<FONT color=red>Riga 46: connection.Open()
</FONT>Riga 47: Dim reader As Odbc.OdbcDataReader = command.ExecuteReader
Riga 48: dt.Load(reader)</PRE> |
File di origine: C:\Inetpub\wwwroot\AspNET_Test\Default.aspx.vb Riga: 46
Potreste darmi delle indicazioni in merito? Tipo perchè non mi carica i dati dove sto sbagliando?
Grazie per il vostro aiuto!