?
Solved

Problems building sql statement using oledbparameter

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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