Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Ich möchte einen parametrisierten SQL-String erzeugen und diesen anschließend absetzen.

Verwende hierzu den Odbc-Provider und greife auf eine Oracle 9i Datenbank zu.

Hier mein Code:

Public Function GetInsertCommand(ByVal con As OdbcConnection) _

As OdbcCommand

Dim strSQL As String = _

"INSERT INTO processstep (prst_id, prst_name) "

strSQL &= "Values(:ID, :Name)"

Dim cmd As OdbcCommand = New OdbcCommand(strSQL, con)

' die Parameter der Parameters-Auflistung hinzufügen

cmd.Parameters.Add(":ID", OdbcType.Int, 18)

cmd.Parameters.Add(":Name", OdbcType.VarChar, 30)

Return cmd

End Function

Public Function SubmitAddedRow(ByVal cmd As OdbcCommand, _

ByVal row As DataRow) As Integer

' Parameter füllen

cmd.Parameters(":ID").Value = row("prst_id")

cmd.Parameters(":Name").Value = row("prst_name")

Return cmd.ExecuteNonQuery()

End Function

Wenn ich das so absetze, wird der Datensatz nicht hinzugefügt. Wenn ich allerdings dem cmd.CommandText den SQL-String komplett zuweise, bevor ich cmd.ExecuteNonQuery() aufrufe, klappt alles.

Was mache ich falsch? Muss ich einen anderen Platzhalter verwenden?

Google konnte mir leider nicht weiterhelfen.

Schon mal vielen Dank im Voraus. Bin für jeden Tipp dankbar.

Hmm, habe es vorher mit einem @ versucht, worauf ich die Fehlermeldung von Oracle "missing expression" bekommen habe. Das mit dem Doppelpunkt habe ich in einem Forum gelesen.

Aber glaube ich habe jetzt herausgefunden wies geht.

Public Function GetInsertCommand(ByVal con As OdbcConnection) _

As OdbcCommand

Dim strSQL As String = _

"INSERT INTO processstep (prst_id, prst_name) "

strSQL &= "Values(?, ?)"

Dim cmd As OdbcCommand = New OdbcCommand(strSQL, con)

' die Parameter der Parameters-Auflistung hinzufügen

cmd.Parameters.Add("prst_id", OdbcType.Int, 18)

cmd.Parameters.Add("prst_name", OdbcType.VarChar, 30)

Return cmd

End Function

Public Function SubmitAddedRow(ByVal cmd As OdbcCommand, _

ByVal row As DataRow) As Integer

' Parameter füllen

cmd.Parameters("prst_id").Value = row("prst_id")

cmd.Parameters("prst_name").Value = row("prst_name")

Return cmd.ExecuteNonQuery()

End Function

Trotzdem vielen Dank für die schnelle Antwort! :uli

Das ist jetzt hoffentlich die richtige Lösung, funktionieren tuts jedenfalls.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.