Currently I'm develop a system using VB.NET. I have the following query for UPDATE. This query is work when I run in SQL Developer
UPDATE CCS2_TBL_INSPECTION_STANDARD SET CCSEQREVITEM = :CCSEQREVITEM,
CCSREVEFFECTIVEDATE = TO_DATE(:CCSREVEFFECTIVEDATE,'DD/MM/YYYY') WHERE
CCSEQID = :CCSEQID
But when I try applied this query in VB.net, its not work. Actually the flow for this update function is work but when I update the data, it is not working. For example, I want update name from 'Ali' to 'Abu', when I click the update button, there popup windows says that "Update success" but the name is not change to 'Abu', it still 'Ali'. There no error when I execute. Anyone know? Below VB.net code:
Protected Sub editInspectionRev(eqid As String)
Dim xSQL As New System.Text.StringBuilder
xSQL.AppendLine("UPDATE CCS2_TBL_INSPECTION_STANDARD")
xSQL.AppendLine("SET")
xSQL.AppendLine("CCSEQREVITEM = :CCSEQREVITEM, CCSREVEFFECTIVEDATE = TO_DATE(:CCSREVEFFECTIVEDATE,'DD/MM/YYYY')")
xSQL.AppendLine("WHERE CCSEQID = :CCSEQID")
Using cn As New OracleConnection(ConString)
cn.Open()
Dim cmd As New OracleCommand(xSQL.ToString, cn)
cmd.Connection = cn
cmd.Parameters.Add(":CCSEQREVITEM", txtRevContent.Text)
cmd.Parameters.Add(":CCSREVEFFECTIVEDATE", txtRevEffDate.Text)
cmd.Parameters.Add(":CCSEQID", eqid)
cmd.ExecuteNonQuery()
cn.Close()
End Using
success3.Visible = True
DisplayRevisionDetails()
End Sub
The problem is that you have executed the transaction but failed to COMMIT it. There is an example of the correct method here, which I will reproduce in part below for posterity
Using connection As New OracleConnection(connectionString)
connection.Open()
Dim command As OracleCommand = connection.CreateCommand()
Dim transaction As OracleTransaction
' Start a local transaction
transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)
' Assign transaction object for a pending local transaction
command.Transaction = transaction
...
command.ExecuteNonQuery()
transaction.Commit()
Observe that we have begun the transaction, and then committed it after executing.
Related
With some vb.net code I try to retrieve data from an Oracle database (simplified example):
strQuery = "Select 2.3, 2.3/1, 2.3/3.1 From Owner.TableName Where ROWNUM < 10"
Dim da As OracleDataAdapter
da = New OracleDataAdapter(strQuery, ConnectionString)
da.Fill(GetData)
This results in an "Specified cast is invalid" error.
The 2.3/3.1 is the problem.
I learned from "Specified cast is not valid" when populating DataTable from OracleDataAdapter.Fill() that Oracle works with a higher precision than dot net can handle and that I should use SuppressGetDecimalInvalidCastException in the OracleDataAdapter. But I don't know how to code it in VB.net. Can anyone help me?
Automatic translation from the C# code did not work.
The C# code itself did not work for me (probably due to the fact that I don't know how to handle the async stuff) and if I simplify it to
string queryString = "Select 2.3, 3.1 From owner.table";
string connectionString = "Data Source=Data.plant.be/database;User ID=****;Password=****";
var table = new DataTable();
var connection = new OracleConnection(connectionString);
var command = new OracleCommand(queryString, connection);
var adapter = new OracleDataAdapter(command) {
SuppressGetDecimalInvalidCastException = true
};
adapter.Fill(table);
I get error CS0117: OracleDataAdaptor does not contain a definition for SuppressGetDecimalInvalidCastException.
Extra info:
As proposed by #Andrew-Morton - thank you Andrew - I wrote:
Dim table = New DataTable()
Dim connection = New OracleConnection(ConnectionString)
Dim cmd = New OracleCommand(strQuery, connection)
Dim adapter = New OracleDataAdapter(cmd) With {.SuppressGetDecimalInvalidCastException = True}
adapter.Fill(GetData)
But I get BC30456: SuppressGetDecimalInvalidCastException is not a member of 'OracleDataAdapter'.
Remark: I have version 19.6 of Oracle.ManagedDataAccess.
I could not install package 'Oracle.ManagedDataAccess 21.9.0'. I Get: You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I am able to add call attrs using 'Genesyslab.Platform.Voice.Protocols.TServer.Requests.Userdata.RequestAttachUserData' when the call is online but how to do when the call is dropped?
I found this in WDE
void SelectDispositionCodeSetAttachedData(string dispositionCodeValueName);
//
// Summary:
// Update or add the keys of the specificed KeyValueCollection in the attached data
// of the interaction . The current list of attached data can then be retrieved
// using GetAttachedData. If the interaction media type is 'voice' or 'instant message'
// and the interaction is not released the added/updated values are immediately
// committed to T/SIP Server. If the interaction media type is 'voice' or 'instant
// message' and the interaction is released the added/updated values are sent to
// T/SIP Server as a UserEvent when the interaction is marked done (programmatic?aly
// or by Agent). If it is an eServices interaction (e-mail, chat, etc.) and the
// interaction is still handled by the agent the added/updated values are immediately
// committed to Interaction Server. After e-Services interaction is released, no
// further programmatical update is committed to Interaction Server. For all interaction
// types any attached data programmatical update applied after interaction release
// is not reflected in UI controls such as 'Case information'.
This is my code:
Genesyslab.Platform.Commons.Collections.KeyValueCollection keyValueCollectionUpDate = new Genesyslab.Platform.Commons.Collections.KeyValueCollection();
keyValueCollectionUpDate.Add("Business Result", "Platform: Business Result");
keyValueCollectionUpDate.Add("StrAttribute1", "AttachedData.Business Result"); RequestAttachUserData requestAttachUserData= RequestAttachUserData.Create("7012", GetConnectionID(ExtractedArtributes[1][0].Value.ToString()), keyValueCollectionUpDate); IMessage respondingEvent2=tserverProtocol.Request(requestAttachUserData);
Need to add call attts after the call is dropped
You can't update attached data when the call is dropped.
I do a workaround by using WDE itself to attach data when agent clicks 'mark done' in WDE custom command.
The way to attach data to voice calls after disconnect, is to send a UserEvent. This does require the AfterCallWork state to be enabled in your environment. You have already mentioned understanding how to insert Commands into the Command Chain. This example Execute function of a command can be inserted into the "BundleClose" Command Chain, prior to the "Close" Command.
This sample is in VB, apologies, but I guess you can easily convert to c#.
Public Function Execute(ByVal parameters As IDictionary(Of String, Object), ByVal progress As IProgressUpdater) As Boolean Implements IElementOfCommand.Execute
' To go to the main thread
If Application.Current.Dispatcher IsNot Nothing AndAlso Not Application.Current.Dispatcher.CheckAccess() Then
Dim result As Object = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, New ExecuteDelegate(AddressOf Execute), parameters, progress)
Return CBool(result)
Else
Dim interactionsBundle As IInteractionsBundle = Nothing
Dim interaction As IInteraction = Nothing
interactionsBundle = parameters("CommandParameter")
interaction = interactionsBundle.MainInteraction
Dim channel As Enterprise.Model.Channel.IClientChannel = interaction.EntrepriseInteractionCurrent.ActiveChannel 'agent.Channel
Dim protocol As IProtocol = channel.Protocol
Dim kvp As Platform.Commons.Collections.KeyValueCollection = New Platform.Commons.Collections.KeyValueCollection()
kvp.Add("keyname", "keyvalue")
Dim userevent As Platform.Voice.Protocols.TServer.CommonProperties = Platform.Voice.Protocols.TServer.CommonProperties.Create()
userevent.UserData = kvp
Dim connID As Platform.Voice.Protocols.ConnectionId = Nothing
Dim interactionVoice as IInteractionVoice = TryCast(interaction, IInteractionVoice)
If interactionVoice IsNot Nothing Then
userevent.UserEvent = Platform.Voice.Protocols.TServer.Events.EventUserEvent.MessageId
connID = New Platform.Voice.Protocols.ConnectionId(interactionVoice.TConnectionId)
Dim strDN As String = Nothing
'ensure the correct DN is passed when attaching reason codes, in case agent is logged into multiple DNs
Dim devices() As Enterprise.Model.Device.IDevice = interactionVoice.Device
Dim device As Enterprise.Core.DN = devices(0)
strDN = device.Name
userevent.ThisDN = strDN
userevent.ConnID = connID
Dim req = Platform.Voice.Protocols.TServer.Requests.Special.RequestSendEvent.Create()
req.UserEvent = userevent
'send request
protocol.Send(req)
End If
End If
End Function
I´m trying to develop a system that reproduces a quiz game. Basically it´s developed with vb (vs 2017) and microsoft access database.
In certain point after the player choose the wrong answer, the system compiles the results with name, amount of righ questions and maximum score.
Aftewards it should record in the database the results., but, it doensnt make it.
My code follow bellow:
Sub RegistraJogo()
Try
Dim Conn As New OleDbConnection
Conn.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=DbDesafioQuiz.accdb"
Conn.Open()
Dim cmd = Conn.CreateCommand
cmd.CommandText = "INSERT INTO TbRecordes (Nome, Data, Pontos, Acertadas) VALUES (#Jogador, #Datas, #Pts, #Corretas)"
cmd.Parameters.AddWithValue("#Jogador", LbJogador.Text) 'nome do jogador
cmd.Parameters.AddWithValue("#Datas", CStr(Now())) 'data do jogo
cmd.Parameters.AddWithValue("#Pts", CStr(PontosTotais * QtdRespondidas)) 'variáveis com valores de pontos e qtd de questões resp
cmd.Parameters.AddWithValue("#Corretas", QtdRespondidas) 'qtd de questões respondidas
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
receivedData = 0
End Sub
Someone could help me, indicanting what i´m doing wrong? Thanks in advance.
I´ve changed the connection string, putting the complete address of database, like:
"c:\temp\dbdesafioquiz.accdb"
For x=0 To 2
Dim FO As String
Dim DataQuery1 As String
DataQuery1 = "Select * from dole_employees WHERE fullname like '%" & Temp_Employees_Name & "%'"
mysqlcommand = New MySqlCommand(DataQuery1, mconnection)
readme = mysqlcommand.ExecuteReader()
While readme.Read()
FO = readme(1)
End While
readme.Close()
MsgBox(FO)
Next
After it displays the value in FO once, an unhandled exception error occurs. What should I do with that?
Here is the additional information to unhandled exemption error.
Additional information: There is already an open DataReader associated with this Connection which must be closed first.
But there is already a readme.close() so why does this happen?
I have a Crystal Reports app that I am loading through VS2010. I have the CR Runtime 13.0.2 loaded on my machine. When I run the app using debug, it works fine. (Great in fact.) But when I install the application that is built (even on the VERY same dev machine.) the TestConnection line comes back false, which indicates to me that it's not connecting properly to my database.
If I don't put this code in there, the app prompts for login credentials at THIS line:
Me.CrystalReportViewer1.ReportSource = reportDocument1
But the DB Name and Server Name are incorrect and grayed out, and anything that I put in UserName and PW doesn't work.
I've searched google and tried any number of "fixes" and NOTHING gets it to work.
I also used database expert to "update" my datasource, and ran a "verify database" from design mode and still the same thing happens.
Here is my code:
Private Function ConnectReport(sDatabaseFile As String, _serverName As String, ReportDocument1 As ReportDocument)
ReportDocument1.SetDatabaseLogon("sa", "sqlAdmin2008", _serverName, sDatabaseFile, True)
For x As Integer = 0 To ReportDocument1.DataSourceConnections.Count - 1
ReportDocument1.DataSourceConnections(x).SetConnection(_serverName, sDatabaseFile, "sa", "sqlAdmin2008")
Next
For Each cTable As Table In ReportDocument1.Database.Tables
If cTable.Name <> "Command" Then
SetTableConnectionInfo(cTable, sDatabaseFile, _serverName)
End If
Next
For Each obj As ReportObject In ReportDocument1.ReportDefinition.ReportObjects
If obj.Kind = ReportObjectKind.SubreportObject Then
Dim subReport As SubreportObject = CType(obj, SubreportObject)
Dim subReportDocument As ReportDocument = ReportDocument1.OpenSubreport(subReport.SubreportName)
ConnectReport(sDatabaseFile, _serverName, subReportDocument)
End If
Next
End Function
Private Function SetTableConnectionInfo(cTable As Table, sDatabaseFile As String, _serverName As String)
Dim logonInfo As TableLogOnInfo = cTable.LogOnInfo
Dim connInfo As ConnectionInfo = New ConnectionInfo()
connInfo.DatabaseName = sDatabaseFile
connInfo.ServerName = _serverName
connInfo.UserID = "sa"
connInfo.Password = "sqlAdmin2008"
'connInfo.Type = ConnectionInfoType.SQL
logonInfo.ConnectionInfo = connInfo
cTable.ApplyLogOnInfo(logonInfo)
If cTable.TestConnectivity = False Then
Throw New ApplicationException("Cannot connect Crystal Reports to Database.")
End If
cTable.Location = sDatabaseFile & "." & "dbo" & "." & cTable.Location
End Function
It would seem to me that you need to pass the table in as a reference like this.
Private Function SetTableConnectionInfo(ref cTable As Table, sDatabaseFile As String, _serverName As String)