Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problems building sql statement using oledbparameter

Posted on 2004-08-02
3
Medium Priority
?
422 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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