Monday, March 26, 2012

Having a hard time connecting to sample SQL database from ASP.Net Page

I am working through the book ASP.Net Unleashed Second Addition. I am trying to open a simple database connection. (using the sample "pubs" db from SQL Server)
I have copied the author's code exactly, but it just won't work. I keep getting this error:
What am I doing wrong???Confused [*-)]

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:BC30182: Type expected.
Source Error:
Line 5: Line 6: Sub Page_LoadLine 7: Dim conPubs As SqlConnectionLine 8: conPubs = New SqlConnection( "server=localhost;uid=webuser;pwd=secret;database=pubs" )Line 9: conPubs.Open()
What namespaces have you imported?|||Coding for my namespace is
<%@. Import Namespace="System.Data.SqlClient" %>
This is copied directly from the authors example.... so I don't know if it is right lolWink [;)]
Then under the page_load event
I typed:
<script Runat="server">
Sub Page_Load
Dim conPubs as SqlConnection
conPubs = New SqlConnection( "Server=localhost;uid=sa;pwd=secret;database=pubs" )
conPubs. Open()
End Sub
</script>
The text "Connection Opened!" Is supposed to show up if the coding is correct...
Help hehe just a beginner :)|||Does anyone know some awesome websites that teach you Visual Studio.Net 2003 and database stuff? I have the hardest time finding things in the MSDN library....|||Try:
http://learnvisualstudio.net/|||

I don't know if VB.NEt support the continuation stuff.
If it does, may be u have to put a continuation sign at the end of line 7.
Cheers.

sql

No comments:

Post a Comment