473,666 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help with Database Connection w/ ASP.NET!

web.config

<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>
<!-- application specific settings -->

<appSettings>
<add key="myConnecti on" value="Provider =Microsoft.Jet. OLEDB.4.0;Data
source=Customer s.mdb;" />
</appSettings>

<system.web>
<httpRuntime executionTimeou t="5" maxRequestLengt h="8192"/>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>

</configuration>
--------------------------------------------------------

DataGridEmail.a spx (Connection String)

<%@ Page Language="VB" %>
<%@ Import Namespace="Syst em.Data" %>
<%@ Import Namespace="Syst em.Data.OleDb" %>

<SCRIPT runat="SERVER">

'Modified from Payne Listings 10.10 & 10.11
'declare connection object with page-level scope (use in two
subroutines)

Dim myConnection as NEW
OLEDBConnection (ConfigurationS ettings.AppSett ings("Customers "))

Sub Page_Load(obj as Object, e as EventArgs)
IF NOT Page.IsPostBack then subFillDataGrid ()
END Sub

Sub subFillDataGrid (Optional EditIndex as integer=-1)
'If Datagrid is in edit mode then specify row to edit
IF NOT EditIndex.Equal s(Nothing) then dgData.EditItem Index = EditIndex

'Initialize command object
Dim objCommand as new OleDbCommand ("SELECT CustID, FirstName,
LastName, Email", myConnection)

TRY
myConnection.Op en()
dgData.DataSour ce =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)
dgData.DataBind ()
CATCH objError as Exception
lblMessage.text += "<br />FillDataGrid "
lblMessage.text += "<br />Error message - " & objError.Messag e
lblMessage.text += "<br />Error source - " & objError.Source
END TRY

END Sub
--------------------------------------------

My error is as follows:

Error message - The ConnectionStrin g property has not been initialized.
Error source - System.Data

Any help would be greatly appreciated!

Nov 19 '05 #1
6 1175
Hi, I think this should help :)

Dim myConnection as NEW
OLEDBConnection (ConfigurationS ettings.AppSett ings("myConnect ion"))

Your key for the connection string in <appSettings> is "myConnecti on" NOT
"Customers"

"Sparky Arbuckle" wrote:
web.config

<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>
<!-- application specific settings -->

<appSettings>
<add key="myConnecti on" value="Provider =Microsoft.Jet. OLEDB.4.0;Data
source=Customer s.mdb;" />
</appSettings>

<system.web>
<httpRuntime executionTimeou t="5" maxRequestLengt h="8192"/>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>

</configuration>
--------------------------------------------------------

DataGridEmail.a spx (Connection String)

<%@ Page Language="VB" %>
<%@ Import Namespace="Syst em.Data" %>
<%@ Import Namespace="Syst em.Data.OleDb" %>

<SCRIPT runat="SERVER">

'Modified from Payne Listings 10.10 & 10.11
'declare connection object with page-level scope (use in two
subroutines)

Dim myConnection as NEW
OLEDBConnection (ConfigurationS ettings.AppSett ings("Customers "))

Sub Page_Load(obj as Object, e as EventArgs)
IF NOT Page.IsPostBack then subFillDataGrid ()
END Sub

Sub subFillDataGrid (Optional EditIndex as integer=-1)
'If Datagrid is in edit mode then specify row to edit
IF NOT EditIndex.Equal s(Nothing) then dgData.EditItem Index = EditIndex

'Initialize command object
Dim objCommand as new OleDbCommand ("SELECT CustID, FirstName,
LastName, Email", myConnection)

TRY
myConnection.Op en()
dgData.DataSour ce =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)
dgData.DataBind ()
CATCH objError as Exception
lblMessage.text += "<br />FillDataGrid "
lblMessage.text += "<br />Error message - " & objError.Messag e
lblMessage.text += "<br />Error source - " & objError.Source
END TRY

END Sub
--------------------------------------------

My error is as follows:

Error message - The ConnectionStrin g property has not been initialized.
Error source - System.Data

Any help would be greatly appreciated!

Nov 19 '05 #2
From your example your setting in <appSettings> is called "myConnecti on" and
in the code you use "ConfigurationS ettings.AppSett ings("Customers ")".
It may be good to debug it in steps, put a break and ensure you get the
right value from AppSettings. After that stick it into the connection string
and debug further.
"Sparky Arbuckle" <tw*@secureroot .com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
web.config

<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>
<!-- application specific settings -->

<appSettings>
<add key="myConnecti on" value="Provider =Microsoft.Jet. OLEDB.4.0;Data
source=Customer s.mdb;" />
</appSettings>

<system.web>
<httpRuntime executionTimeou t="5" maxRequestLengt h="8192"/>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>

</configuration>
--------------------------------------------------------

DataGridEmail.a spx (Connection String)

<%@ Page Language="VB" %>
<%@ Import Namespace="Syst em.Data" %>
<%@ Import Namespace="Syst em.Data.OleDb" %>

<SCRIPT runat="SERVER">

'Modified from Payne Listings 10.10 & 10.11
'declare connection object with page-level scope (use in two
subroutines)

Dim myConnection as NEW
OLEDBConnection (ConfigurationS ettings.AppSett ings("Customers "))

Sub Page_Load(obj as Object, e as EventArgs)
IF NOT Page.IsPostBack then subFillDataGrid ()
END Sub

Sub subFillDataGrid (Optional EditIndex as integer=-1)
'If Datagrid is in edit mode then specify row to edit
IF NOT EditIndex.Equal s(Nothing) then dgData.EditItem Index = EditIndex

'Initialize command object
Dim objCommand as new OleDbCommand ("SELECT CustID, FirstName,
LastName, Email", myConnection)

TRY
myConnection.Op en()
dgData.DataSour ce =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)
dgData.DataBind ()
CATCH objError as Exception
lblMessage.text += "<br />FillDataGrid "
lblMessage.text += "<br />Error message - " & objError.Messag e
lblMessage.text += "<br />Error source - " & objError.Source
END TRY

END Sub
--------------------------------------------

My error is as follows:

Error message - The ConnectionStrin g property has not been initialized.
Error source - System.Data

Any help would be greatly appreciated!

Nov 19 '05 #3
Error message - No value given for one or more required parameters.
Error source - Microsoft JET Database Engine

I have no idea what is going on here. I can tell that something is
starting to work.

Thanks everyone for the prompt replies!

Nov 19 '05 #4
LOFL!

I selected from the database originally:

Dim objCommand as NEW OLEDBCommand ("SELECT CustID, FirstName,
LastName, Email", myConnection)

I forgot to add FROM tblCustomers

Oh man, I love ASP.NET debugging. It was ready to SELECT but had no
idea where to SELECT FROM!

Thanks everyone. Since everyone is so helpful I will probably be back!

Nov 19 '05 #5
Now I run into another problem when I go to add a customer to the
database.

Number of query values and destination fields are not the same. -->
Error message that I get.

My code is as follows:

Sub Insert_onclick( obj as object, e as eventargs)
'insert new data
Dim strText as string
Dim strSQL as string = "INSERT INTO tblCustomers " & _
"(CustID, FirstName, LastName, Email) VALUES (" & _
"'" & CleanData(tbFNa me.text) & "'," & _
"'" & CleanData(tbLNa me.text) & "')" & _
"'" & CleanData(tbEma il.text) & "')"

tbFName.text = ""
tbLName.text = ""
tbEmail.text = ""

ExecuteSQL(strS QL)
subFillDataGrid ()
END Sub
----------------------------------------------------

I don't understand how it is not updating. All the fields that need to
be updated are included in my Subroutine. Any suggestions.

Nov 19 '05 #6
Nevermind. I got it. It seems that the Error Debugging script is
pretty worthless. I was missing a parentheses! Damn you ASP.NET!

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4352
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland Interbase database. To do this, I copied and renamed the source files for working with a SQL Server database (SqlCommandWrapper.cs/SqlDatabase.cs to InterbaseCommandWrapper.cs/InterbaseDatabase.cs). I then changed all
12
3248
by: Joe Cool | last post by:
As most of you are aware, when you close a VB.NET connectrion to a SQL server, the connection doesn't actually drop right then and there. From my tests, using VB.NET 2003 and SQL2K, the connection doesn't timeout and drop off for 6 1/2 minutes. How can one force this connection to immediately drop off with code?
7
2123
by: Tee | last post by:
Hi, I need some help here for DSN connection string. I know it's not recommended to use DSN, even I dont like it as well ... but for now, my situation is I am using a shared hosting. I do not have write access to my web root folder, I have a folder specialy for database. I am currently using access, it is just for testing purpose. here's the info:
1
1418
by: Hugh G. Johnson | last post by:
OK. I'm totally a Newb, so cut me some slack. Here it goes... With all these high falutin features of asp.net do I still need a dsn for the SQL database/server? Or is this enough to turn the lights on? <appSettings> <add key="DBProvider" value="MSSQL" /> <add key="DBConn" value="data source=server;initial catalog=database;user
16
2306
by: peshekeedweller | last post by:
Using asp.net 1.1. vb.net 2003. I am trying to connect to a remote sql server 2000 on a virtual machine running windows 2000 server. I can connect through the server explorer in visual studio, but cannot connect through code. I have done it before and can not do it now; I don't know what changed. (I also cannot connect to local Access database through code though I can from server explorer.) The code is: conn = New SqlConnection("data...
15
4597
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
13
5781
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table CatalogImage where imgID also needs to be placed. Below is my code behind to carry the catID using the Select @@Identity and insert imgID to the bridge table. No data is being entered into the bridge table.
6
2279
crystal2005
by: crystal2005 | last post by:
Hello guys, I'm a beginner in Java application programming. I started to write a Java application in which link to MS Access database. I encountered a problem in deletion function. E.g. I would like to delete one record in database, it always shows "record not found" in my program, even if the data has been deleted. I tried to used function for each choices. But the compiler showed that we can't used function in static void. Is there...
4
1643
by: Mike P2 | last post by:
Hi. I'm writing controls that have to query the database, and it bothers me that I might have several of these controls on a page that each create, open, and close their own connection with the same connection string, and the page class has a connection object too. I'm using the code-behind way of doing things, and I considered leaving the database connection open as a field in the page's class and somehow letting the controls use that...
6
2979
by: zaina | last post by:
hi everybody i am nwebie in this forum but i think it is useful for me and the member are helpful my project is about connecting client with the server to start exchanging messages between them. to be more clear we process this purpose we serve this to the student in the university. how?? student will send a message that contains his name,id and request by format the server want such as zaina-20024008-grade. the grade is the request...
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.