473,804 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with .aspx.vb code

I'm working on a problem with a form with 6 textboxes and a submit
button for adding data to an Access database.I changed a few things
and got it down to 1 error!. I have a Sub
Page_Load and a Sub btnAdd:
(It still doesn't like the 'SourceVersion' in the Sub Page_Load).
Also
I viewed the .aspx in the browser and got an error which I posted
complete at the bottom of this post). Thanks for any clues... I'm
almost there!!

Imports System.Data
Imports System.Data.Ole Db
Public Class Default5
Inherits System.Web.UI.P age
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim cnn As OleDbConnection = _
New OleDbConnection ("Data Source=(local); " & _
"Initial Catalog=Assets; Integrated Security=SSPI")
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapte r = New OleDbDataAdapte r()
If IsPostBack Then
Dim cmdSelect As OleDbCommand = _
cnn.CreateComma nd()
cmdSelect.Comma ndType = CommandType.Tex t
cmdSelect.Comma ndText = _
"SELECT (Asset Number, Description, Serial_Number, Mfg, Asset Type,
RDCnumber) FROM Assets"
Dim cmdInsert As OleDbCommand = _
cnn.CreateComma nd()
cmdInsert.Comma ndType = CommandType.Tex t
cmdInsert.Comma ndText = _
"INSERT INTO Assets " & _
"(Asset Number, Description, Serial_Number, Mfg, Asset Type,
RDCnumber) " & _
"VALUES(@Asset_ Number, @Description, @Serial_Number, @Mfg,
@AssetType,
@RDCnumber"
cmdInsert.Param eters.Add("@txt Asset_Number",
OleDbType.Doubl e, 12, "Asset_Numb er")
cmdInsert.Param eters.Add("@txt Description",
OleDbType.WChar , 40, "Descriptio n")
cmdInsert.Param eters.Add("@txt Serial_Number",
OleDbType.WChar , 30, "Serial_Number" )
cmdInsert.Param eters.Add("@txt Mfg", OleDbType.WChar , 30,
"Mfg")
cmdInsert.Param eters.Add("@txt AssetType",
OleDbType.WChar ,
30, "AssetType" )
cmdInsert.Param eters.Add("@txt RDCNumber",
OleDbType.WChar ,
30, "RDCnumber" )
Dim SourceVersion As DataRowVersion
SourceVersion = DataRowVersion. Original
da.SelectComman d = cmdSelect
da.InsertComman d = cmdInsert
da.Fill(ds, "Assets")
End If
End Sub
Private Sub btnAdd_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnAdd.Click
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapte r = New OleDbDataAdapte r()
Dim dr As DataRow = ds.Tables("Asse ts").NewRow()
dr(0) = txtAsset_Number .Text
dr(1) = txtDescription. Text
dr(2) = txtSerial_Numbe r.Text
dr(3) = txtMfg.Text
dr(4) = txtAssetType.Te xt
dr(5) = txtRDCnumber.Te xt
ds.Tables("Asse ts").Rows.Add(d r)
da.Update(ds, "Assets")
End Sub
End Class
_______________ ___________
Server Error in '/' Application.
---------------------------------------------------------------------------*-----
An OLE DB Provider was not specified in the ConnectionStrin g. An
example would be, 'Provider=SQLOL EDB;'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Argument Exception: An OLE DB Provider was
not specified in the ConnectionStrin g. An example would be,
'Provider=SQLOL EDB;'.
Source Error:
Line 5: Private Sub Page_Load(ByVal sender As System.Object, _
Line 6: ByVal e As System.EventArg s) Handles MyBase.Load
Line 7: Dim cnn As OleDbConnection = _
Line 8: New OleDbConnection ("Data Source=(local); " & _
Line 9: "Initial Catalog=Assets; Integrated Security=SSPI")
Source File: E:\kunden\homep ages\26\d190091 667\Default5.as px.vb
Line: 7
Stack Trace:
[ArgumentExcepti on: An OLE DB Provider was not specified in the
ConnectionStrin g. An example would be, 'Provider=SQLOL EDB;'.]
System.Data.Ole Db.OleDbConnect ionString.Valid ateProvider(Str ing
progid) +1044303
System.Data.Ole Db.OleDbConnect ionString.Valid ateConnectionSt ring(String
connectionStrin g) +221
System.Data.Ole Db.OleDbConnect ionString..ctor (String
connectionStrin g, Boolean validate) +271
System.Data.Ole Db.OleDbConnect ionFactory.Crea teConnectionOpt ions(String
connectionStrin g, DbConnectionOpt ions previous) +36
System.Data.Pro viderBase.DbCon nectionFactory. GetConnectionPo olGroup(String
connectionStrin g, DbConnectionPoo lGroupOptions poolOptions,
DbConnectionOpt ions& userConnectionO ptions) +125
System.Data.Ole Db.OleDbConnect ion.ConnectionS tring_Set(Strin g
value) +56
System.Data.Ole Db.OleDbConnect ion.set_Connect ionString(Strin g
value) +4
System.Data.Ole Db.OleDbConnect ion..ctor(Strin g connectionStrin g)
+21
Default5.Page_L oad(Object sender, EventArgs e) in E:\kunden
\homepages\26\d 190091667\Defau lt5.aspx.vb:7
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +99
System.Web.UI.C ontrol.LoadRecu rsive() +47
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
+1061

Aug 8 '07
13 1633
slinky wrote:
OK I double checked and corrected any incident of misspelling or
brackets missing and corrected those.
And now it looks like?
But still the browser brings up
this: (And I know nothing about
reading a stack)

Also, do I have this syntaxed correctly (ignore the '& _'s as they are
just from reformat on paste)?:

New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=Server.M apPath(~/App_Data/Lowes.mdb));" & _
"Initial Catalog=Assets; Integrated Security=SSPI")
No. You have put Server.MapPath inside the string. There it doesn't mean
anything at all. Concatenate the return value from the method into the
string:

New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=" & Server.MapPath( ~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets; Integrated Security=SSPI")

--
Göran Andersson
_____
http://www.guffa.com
Aug 8 '07 #11
I tried this exact paste:

New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=" & Server.MapPath( ~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets; Integrated Security=SSPI")

And it didn't like the format so I redid it to:

New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data &
_
Source=" & Server.MapPath( ~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets; Integrated Security=SSPI")

And that didn't work either, so I tried just one long string:

New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=" & Server.MapPath( ~/App_Data/Lowes.mdb) & ";" "Initial
Catalog=Assets; Integrated Security=SSPI")

or:

New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=" & Server.MapPath & _
(~/App_Data/Lowes.mdb) & ";" "Initial Catalog=Assets; Integrated
Security=SSPI")

Then it doesn't allow the "~" symbol. I see your point about putting
Server.MapPath outside the rest of the code, but I tried these
variations and couldn't get the syntax to be accepted.

Any ideas of what I'm doing wrong? And I really do appreciate your
help for this newbie!
On Aug 8, 6:42 pm, Göran Andersson <gu...@guffa.co mwrote:
No. You have put Server.MapPath inside the string. There it doesn't mean
anything at all. Concatenate the return value from the method into the
string:

New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=" & Server.MapPath( ~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets; Integrated Security=SSPI")

--
Göran Andersson
_____http://www.guffa.com

Aug 9 '07 #12
slinky wrote:
I tried this exact paste:

New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=" & Server.MapPath( ~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets; Integrated Security=SSPI")
That's only two lines, not three. I just edited the code that you posted.

I forgot the quotes around the string in the call to MapPath.

You really should read up a bit on the basic elements in the
programming, like strings and method calls. If you just copy and paste
code that you don't understand, you won't learn anything.

Code posted in newsgroups and articles often has small mistakes like
this, if you don't understand the code you can't fix those mistakes and
use the code.

--
Göran Andersson
_____
http://www.guffa.com
Aug 10 '07 #13
On Aug 10, 10:52 pm, Göran Andersson <gu...@guffa.co mwrote:
slinky wrote:
I tried this exact paste:
New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=" & Server.MapPath( ~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets; Integrated Security=SSPI")

That's only two lines, not three. I just edited the code that you posted.

I forgot the quotes around the string in the call to MapPath.

You really should read up a bit on the basic elements in the
programming, like strings and method calls. If you just copy and paste
code that you don't understand, you won't learn anything.

Code posted in newsgroups and articles often has small mistakes like
this, if you don't understand the code you can't fix those mistakes and
use the code.

--
Göran Andersson
_____http://www.guffa.com
Agree with Göran.

http://groups.google.com/group/micro...fa4e582f3bc1e6

Aug 10 '07 #14

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

Similar topics

1
2804
by: sathya | last post by:
hi, i have problem in httphandler, my problem is that when i am trying to use server.execute(/default.aspx) i am getting error.... Here i am trying to redirect from home.aspx to default.aspx (both file isin sharepoint).I have give a copy of my code below..
5
3049
by: | last post by:
Hi, I'm trying to use the cookie munging session handling behaviour of asp.net instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I change the setting in web.config everything seems to work fine as long as I'm using relative paths. The problem is I've got a menuing system that's generated from a site-wide template - so I use a fixed path from the application root - (ie:...
6
2736
by: Shamin | last post by:
Hi, Thanks in advance for answering to my Question. I'm stuck with this problem and would really appreciate any help. I have 2 aspx files (Main.aspx and ReportViewer.aspx). Main.aspx has a datagrid which is populated with list of report names. When the user click on the name of a report, I display a panel that has a button which on clicking will run the report. The report will open in ReportViewer.aspx, This page has a Report Document...
6
3818
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length is more that 1249 bytes, then the progress bar of the browser will move too slow and then displaying that the page not found!!!! If the message is less than or equal to 1249 then no problem.
7
5239
by: Ankit Aneja | last post by:
I put the code for url rewrite in my Application_BeginRequest on global.ascx some .aspx pages are in root ,some in folder named admin and some in folder named user aspx pages which are in user folder are using this code of url rewrite project is running completely fine on localhost but after uploading first page (http://emailware.net.temporary.domain.name/user/index.aspx) is fine but as i click 123 Easy-CD Ripper
2
2511
by: MS News Public | last post by:
Hi I have an asp.net 2.0 project and am experiencing a problem. In the project, I am trying to make use of Membership. I have one Role, called "Basic User" and two users - "admin" and "test". "admin" is a member of the Role but "test" is not.
0
2122
by: james.mcdonagh | last post by:
Hi I am a newbie using nAnt for .net 2.0. As such I have not come across this bug before, and I would be happy of any help that you may be able to provide. In order to help I have included the nant file which is causing the problem, the object code that is not being built and the error message which is being produced. The weird thing is that VS.net builds without a problem. And the intellisense within the object WorkQueue knows that...
1
6181
by: jamesmcdonagh | last post by:
Hi newbie using nAnt for .net 2.0. I would be happy of any help that you may be able to provide. The weird thing is that VS.net builds without a problem. And the intellisense within the object WorkQueue knows that Master is referring to the PanelManager reference. nant file ------------------------------------------------------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8"?>...
4
2652
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. - Why is this happening? - Can I disable automatic declaration and have everything be declared manually? - Any other options to fix this? Thanks in advance. Goran Djuranovic
0
1377
by: Syoam4ka | last post by:
My project is about jewellery. I have devided my jewelery into main types, which each one of them has sub types, and each one those sub types has the jewellery. I have a tabcontainer. It includes tabpanels such as:Catalog,Terms,SiteMap.ViewCart ,etc. All the jewellery Intro is in the Catalog panel. when I first click the Catalog panel it Introduces me all the main types of the jewellery(It's all done dynamically from the cs file).The...
0
9716
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
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10359
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
10101
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...
0
9177
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
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
5536
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...
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.