connecting to database

access United States
  • 16 years ago

    i am generating a dataset with the following code

    Public Sub doInsert(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
           If e.CommandName = "Insert" Then
               Dim storID As String
               Dim txtStorID As TextBox
               txtStorID = e.Item.FindControl("add_storID")
               storID = txtStorID.Text

               Dim storName As String
               Dim txtStorName As TextBox
               txtStorName = e.Item.FindControl("add_storName")
               storName = txtStorName.Text

               Dim storAddress As String
               Dim txtStorAddress As TextBox
               txtStorAddress = e.Item.FindControl("add_storAddress")
               storAddress = txtStorAddress.Text

               Dim storCity As String
               Dim txtStorCity As TextBox
               txtStorCity = e.Item.FindControl("add_city")
               storCity = txtStorCity.Text

               Dim storState As String
               Dim txtStorState As TextBox
               txtStorState = e.Item.FindControl("add_state")
               storState = txtStorState.Text

               Dim storZip As String
               Dim txtStorZip As TextBox
               txtStorZip = e.Item.FindControl("add_zip")
               storZip = txtStorZip.Text

               Dim strSQL As String
               strSQL = "INSERT INTO STORES (id, storname, storaddress, city, state, zip) " _
               & "VALUES (@ID, @storeName, @storeAddr,@city,@state,@zip)"
               Const strConnStr As String = "Provider=MSDAORA.1;user id=schmirv2;data source="";password=""
               'Dim con As New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("conn"))
               Dim con As New OleDb.OleDbConnection(strConnStr)
               Dim cmdExp As New OleDb.OleDbCommand(strSQL, con)
               'cmdExp.CommandType = CommandType.Text
               'con = New SqlConnection(ConfigurationSettings.AppSettings("conn"))
               'cmdExp = New SqlCommand(strSQL, con)
               Dim storIDParam As New OleDb.OleDbParameter("@ID", OleDb.OleDbType.Double, 50)
               storIDParam.Value = storID
               Dim storNameParam As New OleDb.OleDbParameter("@storeName", OleDb.OleDbType.VarChar, 50)
               storNameParam.Value = storName
               Dim storAddParam As New OleDb.OleDbParameter("@storeAddr", OleDb.OleDbType.VarChar, 50)
               storAddParam.Value = storAddress
               Dim storCityParam As New OleDb.OleDbParameter("@city", OleDb.OleDbType.VarChar, 50)
               storCityParam.Value = storCity
               Dim storStateParam As New OleDb.OleDbParameter("@state", OleDb.OleDbType.VarChar, 50)
               storStateParam.Value = storState
               Dim storZipParam As New OleDb.OleDbParameter("@zip", OleDb.OleDbType.VarChar, 50)
               storZipParam.Value = storZip

               dgStores.EditItemIndex = -1
           End If

    basically when i compile i get the error

    System.Data.OleDb.OleDbException: One or more errors occurred during processing of command. ORA-00936: missing expression

    i also get the following error sometimes
    System.InvalidCastException: Object must implement IConvertible

    how can i fix this error so that i can insert into my datagrid

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Java is to JavaScript what Car is to Carpet.” - Chris Heilmann