473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

.aspx.vb code syntax

I'm making a OLE DB connection in code and was wondering if anyone
could identify what the syntax errors would be in this just as it is
pasted (I tried putting & _ at the end of the first line and that
only brought up other errors):

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

Thanks!!

Aug 9 '07 #1
10 1697
Have you looked at connectionstrings.com? Its a good url to bookmark.
Peter
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"slinky" wrote:
I'm making a OLE DB connection in code and was wondering if anyone
could identify what the syntax errors would be in this just as it is
pasted (I tried putting & _ at the end of the first line and that
only brought up other errors):

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

Thanks!!

Aug 9 '07 #2
I looked on connectionstrings.com but it did not have specifics for
what could be wrong with the syntax... thanks though

On Aug 9, 11:20 am, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
Have you looked at connectionstrings.com? Its a good url to bookmark.
Peter
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"slinky" wrote:
I'm making a OLE DB connection in code and was wondering if anyone
could identify what the syntax errors would be in this just as it is
pasted (I tried putting & _ at the end of the first line and that
only brought up other errors):
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets;Integrated Security=SSPI")
Thanks!!- Hide quoted text -

- Show quoted text -

Aug 9 '07 #3
try removing all continuation characters and see if it all works

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup

"slinky" <ca***************@yahoo.comwrote in message
news:11**********************@l70g2000hse.googlegr oups.com...
I'm making a OLE DB connection in code and was wondering if anyone
could identify what the syntax errors would be in this just as it is
pasted (I tried putting & _ at the end of the first line and that
only brought up other errors):

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

Thanks!!

Aug 9 '07 #4
I just did that with this line:

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

I used no continuity characters and the line showed no errors, except
one - it noted the ~ symbol as being not valid, but then errors showed
up in other unexpected places like: 'cnn' is not declared... when my
code (in its entirety below) shows that it IS declared.
__________________________________________________ _______________________________

Imports System.Data
Imports System.Data.OleDb
Public Class Default5
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnn As OleDbConnection = _
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) " &";""Initial
Catalog=Assets;Integrated Security=SSPI")
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
If Not IsPostBack Then
Dim cmdSelect As OleDbCommand = _
cnn.CreateCommand()
cmdSelect.CommandType = CommandType.Text
cmdSelect.CommandText = _
"SELECT ([Asset Number], Description, [Serial Number], Mfg, AssetType,
RDCnumber) FROM Assets"
Dim cmdInsert As OleDbCommand = _
cnn.CreateCommand()
cmdInsert.CommandType = CommandType.Text
cmdInsert.CommandText = _
"INSERT INTO Assets " & _
"([Asset Number], Description, [Serial Number], Mfg, AssetType,
RDCnumber) " & _
"VALUES(@AssetNumber, @Description, @Serial_Number, @Mfg, @AssetType,
@RDCnumber"
cmdInsert.Parameters.Add("@txtAsset_Number",
OleDbType.Double, 12, "[Asset Number]")
cmdInsert.Parameters.Add("@txtDescription",
OleDbType.WChar, 40, "Description")
cmdInsert.Parameters.Add("@txtSerial_Number",
OleDbType.WChar, 30, "[Serial Number]")
cmdInsert.Parameters.Add("@txtMfg", OleDbType.WChar, 30,
"Mfg")
cmdInsert.Parameters.Add("@txtAssetType", OleDbType.WChar,
30, "AssetType")
cmdInsert.Parameters.Add("@txtRDCNumber", OleDbType.WChar,
30, "RDCnumber")
Dim SourceVersion As DataRowVersion
SourceVersion = DataRowVersion.Original
da.SelectCommand = cmdSelect
da.InsertCommand = cmdInsert
da.Fill(ds, "Assets")
End If
End Sub
Private Sub btnAdd_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd.Click
Dim cnn As OleDbConnection = _
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) " &";""Initial
Catalog=Assets;Integrated Security=SSPI")
Dim ds As DataSet = New DataSet()
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
Dim dr As DataRow = ds.Tables("Assets").NewRow()
dr(0) = txtAsset_Number.Text
dr(1) = txtDescription.Text
dr(2) = txtSerial_Number.Text
dr(3) = txtMfg.Text
dr(4) = txtAssetType.Text
dr(5) = txtRDCnumber.Text
ds.Tables("Assets").Rows.Add(dr)
da.Update(ds, "Assets")
End Sub
End Class
__________________________________________________ __________________________________________________ __


On Aug 9, 12:25 pm, "David Wier" <davidw...@davidwier.nospam.com>
wrote:
try removing all continuation characters and see if it all works

David Wierhttp://aspnet101.comhttp://iWritePro.com- One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup

"slinky" <campbellbrian2...@yahoo.comwrote in message

news:11**********************@l70g2000hse.googlegr oups.com...
I'm making a OLE DB connection in code and was wondering if anyone
could identify what the syntax errors would be in this just as it is
pasted (I tried putting & _ at the end of the first line and that
only brought up other errors):
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & Server.MapPath(~/App_Data/Lowes.mdb) & ";" & _
"Initial Catalog=Assets;Integrated Security=SSPI")
Thanks!!- Hide quoted text -

- Show quoted text -

Aug 9 '07 #5
On Aug 9, 7:33 pm, slinky <campbellbrian2...@yahoo.comwrote:
I just did that with this line:

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

Server.MapPath("~/App_Data/Lowes.mdb")

Aug 9 '07 #6
On Aug 9, 7:39 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Aug 9, 7:33 pm, slinky <campbellbrian2...@yahoo.comwrote:
I just did that with this line:
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath(~/App_Data/Lowes.mdb) " &";""Initial
Catalog=Assets;Integrated Security=SSPI")

I guess

Server.MapPath("~/App_Data/Lowes.mdb")
and finally

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

you should understand that the goal of that concatenation is to have a
properly formatted string, for example:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\InetPub\wwwroot
\App_Data\Lowes.mdb;Initial Catalog=Assets;Integrated Security=SSPI

Aug 9 '07 #7
So would this work? I added a couple of continuity characters. Looks
OK but it still doesn't allow the ~ symbol AND it still says the cnn's
are not declared.

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
_
Server.MapPath(~/App_Data/Lowes.mdb) " &";Initial & _
Catalog=Assets;Integrated Security=SSPI")
Aug 9 '07 #8
On Aug 9, 8:13 pm, slinky <campbellbrian2...@yahoo.comwrote:
So would this work? I added a couple of continuity characters. Looks
OK but it still doesn't allow the ~ symbol AND it still says the cnn's
are not declared.

New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
_
Server.MapPath(~/App_Data/Lowes.mdb) " &";Initial & _
Catalog=Assets;Integrated Security=SSPI")
oh, sorry a silly copy typo:

Server.MapPath("~/App_Data/Lowes.mdb")

Aug 9 '07 #9
OK I put this in:

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

But then the " &" part of the second line errors
with: "Comma, ")", or valid expression expected"

Plus any clues as to why the 'cnn' isn't recognized?

On Aug 9, 2:21 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Aug 9, 8:13 pm, slinky <campbellbrian2...@yahoo.comwrote:
So would this work? I added a couple of continuity characters. Looks
OK but it still doesn't allow the ~ symbol AND it still says the cnn's
are not declared.
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
_
Server.MapPath(~/App_Data/Lowes.mdb) " &";Initial & _
Catalog=Assets;Integrated Security=SSPI")

oh, sorry a silly copy typo:

Server.MapPath("~/App_Data/Lowes.mdb")

Aug 9 '07 #10
Instead of
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
_
Server.MapPath("~/App_Data/Lowes.mdb") " &";Initial & _
Catalog=Assets;Integrated Security=SSPI")
Try this:
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
_
Server.MapPath("~/App_Data/Lowes.mdb") & ";Initial " & _
"Catalog=Assets;Integrated Security=SSPI")
Akin
--
akyak at aksoto dot idps dot co dot uk
Aug 10 '07 #11

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

Similar topics

7
by: Gene | last post by:
I have a number of aspx pages on which a single user control appears. All of the aspx pages and the user control make user of code-behind modules. I need for logic in the user control's code-behind...
2
by: Matthias H. | last post by:
Hi guys, Our team has a very strange problem. I hope anybody can help. We have a class called webpage and all our aspx-pages bases on it. Then we have a SYS.IO.File Class which have a...
6
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp;...
21
by: Brett | last post by:
Say I develop an application that has an SQL Server 2000 back end with ASP.NET front end. All the business logic is in the aspx pages. I want to sell this as a package that some one can install...
4
by: Tony Moaikel | last post by:
Hi, I read that it is possible to deploy an asp.net app without the aspx code. Does anyone know about any articles that explain how to do this? Thanks, Tony
1
by: Ronald S. Cook | last post by:
Hi, My ASPX code is trying to read a file on a mapped drive. But I get the error below. Any help would be greatly appreciated. Could not find a part of the path 'Z:\Events.nss'. ...
0
by: James Robertson | last post by:
OK so I have that and get it. Now here is my code, I want to insert the www.mydomain.com?email=username@domain.com to the string "USER@DOMAIN.NET" to accept the variable from elier. How and where?...
2
by: Hiten | last post by:
Is it possible to have more code behind file but that file will have same class in way of partial class, Default Structure I -------------- Homepage.aspx + Homepage.aspx.cs (this .cs file...
2
by: mad.scientist.jr | last post by:
In .NET 2.0, is there any way to include comments in the aspx file that do not get rendered to the client (ie no <!-- -->) ? When I try to include C# comments in a code block in an aspx page,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.