I used this:
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data" &
_
Source=" & Server.MapPath("~/App_Data/Lowes.mdb") & ";" & _
"Initial Catalog=Assets;Integrated Security=SSPI")
But now the bottom line lists syntax errors: "Initial
Catalog=Assets;Integrated Security=SSPI"
Plus the "~" is still being listed as a Not Valid Character.
On Aug 10, 10:19 am, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
> On Aug 10, 2:50 pm, slinky <campbellbrian2...@yahoo.com> wrote:
>
>
>
>
>
> > I'm making a OLE DB connection in code and was wondering if anyone
> > could identify what the syntax errors I have. I've tried countless
> > combinations and all give errors.
>
> > New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data & _
> > Source=" & Server.MapPath("~/App_Data/Lowes.mdb") & ";" & _
> > "Initial Catalog=Assets;Integrated Security=SSPI")
>
> > Thanks!!
>
> > Below is my complete code:
>
> > 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
>
> A quotation mark is missing at the first line
>
> New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data (HERE) &
> _
> Source=" & Server.MapPath("~/App_Data/Lowes.mdb") & ";" & _
> "Initial Catalog=Assets;Integrated Security=SSPI")- Hide quoted text -
>
> - Show quoted text -