Hi there Kendel,
You are correct about the import, and if you recall on the Tutorial in the comments I state that very thing:
"Ok remember that you require the creation of a connection object inorder to access the SQL Database. The basics for the connection string (the means of creating this connection object) is;
Imports System.Data.SqlClient
...
Dim oSQLConn As SqlConnection = New SqlConnection()
....
"
and here futher down in the same post
The updated heading to all ASP.Net Page Code Behinds (still using VB.Net):
' ||||| This is the Connections Object for an SQL DB
Dim MyConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
And further down in the post I state the following as well :
The updated heading to all ASP.Net Page Code Behinds (still using VB.Net):
Imports System.Web.Security ' ||||| Required Class for Authentication
Imports System.Data ' ||||| DB Accessing Import
Imports System.Data.SqlClient
Imports System.Configuration ' |||||| Required for Web.Config appSettings |||||
New Web.Config (partial code only, not the whole file)
<?xml version="1.0" encoding="utf-8"?> <configuration> <!-- ||||| Application Settings ||||| -->
<appSettings>
<add key="strConn" value="Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;"/>
</appSettings>
<system.web>
...
And I just stated a notable change to the strConn in the web.config for SQL 7.0 or greater today.
The SQL Server .NET Data Provider allows you to connect to a Microsoft SQL Server 7.0 or 2000 database. For Microsoft SQL Server 6.5 or earlier, use the OLE DB .NET Data Provider with the "SQL Server OLE DB Provider" (SQLOLEDB).
Note: The SQL Server .NET Data Provider knows which data provider it is. Hence the "provider=" part of the connection string is not needed.
Hope this helps.
With a regards to basic errors like
"something xyz is not declared", and as a means for the me better help everyone better, I would appreciate it if you try to investigate the errors you are getting a little better before posting them here. These are generally just a copy and pastee, coding or syntax error, and a fairly easy to fix once you review your code. Hard and fast rules of .Net Framework requires you to DECLARE all variables!
The SQL version of this is still being worked on, and I will have a step by step guide completed before long, just extremely busy at the moments building an Oracle based system and it is very time consuming.
But I will try to answer any questions you have on this thread or the
new thread whenever I can. So keep the questions coming!
Happy coding
Originally Posted by Kendel
I'm using SQLServer 7.0
My strConnection in web.config
<appSettings>
<add key="connString" value="server=myDBServer;uid=myid;pwd=myPass;database=myDB" />
</appSettings>
For SQL, I common out the Access thing, and use the syntax for SQL as you suggested:
' First is the Connection Object for an Access DB
' Dim MyConn As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("connString"))
' This is the Connections Object for an SQL DB
SqlConnection(ConfigurationSettings.AppSettings("connString"))
and I got the error here saying that SqlConnection was not declared.
I thought the import we need for SQLServer is Imports System.Data.SqlClient
not Imports System.Data.OleDb