Solved

Problems building sql statement using oledbparameter

Posted on 2004-08-02
3
403 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
  • 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 18

Expert Comment

by:DotNetLover_Baan
ID: 11700591
0
 
LVL 17

Expert Comment

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

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now