Bonjour tout le monde,
Je suis debutant en ASP.NET VB et j'ai un petit probleme avec ma page Global.asax
j essay de faire appel a une base de donnees pour peupler une liste asp:DropDownList
voici le code du fichier Global.asax :
<%@Import Namespace="Systeme.Data.SqlClient"%>
<script language="VB" runat="server">
Sub Session_Start(Sender As Object, E As EventArgs)
Dim myConnection As SqlConnection
myConnection = new SqlConnection()
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=SDS.mdb"
myConnection.Open()
Session("myConnection") = myConnection
End Sub
Sub Session_End(Sender As Object, E As EventArgs)
Dim myConnection As SqlConnection
myConnection = CType(Session("myConnection"),SqlConnection)
myConnection.Close()
End Sub
</script>
et voici celui de stock.aspx:
<%@ Page Language="VB" Debug="true" %>
<%@ Register TagPrefix="SDS" TagName="NavBar" Src="NavBar.ascx" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub ChargerListeFamilles()
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim myReader As SqlReader
Dim SQL As String
myConnection = CType(Session("myConnection"),SqlConnection)
SQL = "SELECT * FROM FamilleProduit"
myCommand = new SqlCommand(SQL,myConnection)
myReader = myCommand.ExecuteReader()
ListeFamilles.DataSource = myReader
ListeFamilles.DataValueField = "ID_FamilleProduit"
ListeFamilles.DataTextField = "NomFamille"
ListeFamilles.DataBind()
myReader.Close()
End Sub
Sub Page_Load(Sender As Object, e As EventArgs)
ChargerListeFamilles()
End Sub
</script>
<html>
<head>
<title>Suivi des stocks</title>
<link href="SDS.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<SDS:NavBar id="MyNavBar" SelectedIndex="1" runat="server"></SDS:NavBar><br>
<form runat="server">
<h4> Bienvenue dans le module de suivi des stocks</h4>
<table width="325px" border="0" bgcolor="#dddddd">
<tr>
<td width="60"> Famille
</td>
<td><asp:DropDownList id="ListeFamilles" runat="server" width="250px"></asp:DropDownList></td>
</tr>
</table>
<asp:DataGrid id="EtatStock" runat="server"></asp:DataGrid>
</form>
</body>
</html>
et voici l erreur :
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30002: Type 'SQLConnection' is not defined.
Source Error:
Line 4: Sub Session_Start(Sender As Object, E As EventArgs)
Line 5:
Line 6: Dim myConnection As New SQLConnection()
Line 7: myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=SDS.mdb"
Line 8: myConnection.Open()
Source File: global.asax Line: 6
merci
Huummm....encore un bug