connection and fucntions

heya al- just wanted to find out about linking databases to web page. Ive used a ole database connector with a page I want to display the data in a script part however when i take out the database connection and put it into another aspx file and call the aspx file in the page i want it in- it comes up with errors such as variables not initialised etc.

e.g.

heres my database connection:

<script runat="server">
Sub Page_Load()
Dim dbconn, sql, dbcomm, dbread
dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("linkdb.mdb"))
dbconn.Open()
End Sub
</script>

And heres the fucntion i want to perform in a different web form:

<script runat="server">
sql = "SELECT * FROM Links1"
dbcomm = New OleDbCommand(sql, dbconn)
dbread = dbcomm.ExecuteReader()
customers.DataSource = dbread
customers.DataBind()
dbread.Close()
dbconn.Close()
</script>

And what im doin is calling the code as:

<!--#include file="Database.aspx"-->

But its coming up with errors in the aspx file with the select statement saying dbread, dbcomm etc arent initialised.

The page works if i merge both codes under 1 script and use it in just 1 singular aspx file

Please help

Thanks

[1506 byte] By [s12] at [2007-12-24]
# 1


Those aren't errors, they are warnings. It simply means that you have not assigned a value to the variable prior to its use.

You could probably ignore the warnings in this instance.

PaulPClementIV at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified