Solved

Problems building sql statement using oledbparameter

Posted on 2004-08-02
3
412 Views
Last Modified: 2008-02-01
Using sql db I get the following compile error.

BC30002: Type 'OleDbParameter' is not defined.

I am new at asp so bear with me. I got the following code off of 4guysfromrolla website.
Maybe there is a better way to build the sql statement. I am trying to get the update portion of my datagrid to update after an edit.

Sub CustomerData_Update(sender As Object, e As DataGridCommandEventArgs)
   Dim oDR as System.Data.SQLClient.SQLDataReader
   Dim oCom As System.Data.SQLClient.SqlCommand
   Dim oConn as System.Data.SQLClient.SQLConnection
      
   'Read in the values of the updated row
   Dim indi as String = e.Item.Cells(1).Text
   Dim lname as string = CType(e.Item.Cells(2).Controls(0), TextBox).Text
   Dim mi as string = CType(e.Item.Cells(3).Controls(0), TextBox).Text
   Dim fname as String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
   Dim address1 as String = CType(e.Item.Cells(5).Controls(0), TextBox).Text
   'Construct the SQL statement using Parameters
    Dim strSQL as String = _
      "UPDATE [distributor] SET [lname] = @lname, " & _
      "[UnitPrice] = @UnitPrice, [ProductDescription] = @ProdDesc " & _
      "WHERE [ProductID] = @ProductID"

    oConn = New System.Data.SQLClient.SQLConnection ("server=mssql01.1and1.com; initial catalog=db106189075;uid=dbo106189075;pwd=aZf65Snc")
      oConn.Open()
                  
    'Dim myCommand as OleDbCommand = new OleDbCommand(strSQL, objConn)
      oCom=new System.Data.SQLClient.SQLCommand()
    oCom.CommandType = CommandType.Text

    ' Add Parameters to the SQL query

** the error comes from the below line.
    Dim parameterProdName as OleDbParameter = new OleDbParameter("@lname", OleDbType.text, 75)
    parameterProdName.Value = strName
    oCom.Parameters.Add(parameterProdName)


    oCom.ExecuteNonQuery()   'Execute the UPDATE query
   
    oCom.Close()   'Close the connection
  'Finally, set the EditItemIndex to -1 and rebind the DataGrid
    oCom.EditItemIndex = -1
    Page_Data()        
End Sub
0
Comment
Question by:Jimbo456
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 500 total points
ID: 11700552
Hi there,
you are using "System.Data.SQLClient"... and the parameter you are creating is  OleDbParameter. That's why you are having problems. It should be...
Dim parameterProdName As New SqlParameter("@lname", SqlDbType.VarChar)

Try these links:
http://www.developerfusion.com/show/4278/3/
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlParameterClassTopic.asp

-Baan
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11703407
tell me those aren't your actual SQL server account settings.

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question