Data Type mismatch in criteria expression when Table Adapter Update - vb.net

I have already been searched solution and can't get the right solution yet.
ObjDRow = DataDataSet.Client.Rows.Find(strClientNo)
With ObjDRow
.ClientName = txtClientName.Text.Trim
.ClientAddr = txtAddr.Text.Trim
If txtRegOffice.Text = "" Then
.ClientRegOfficeAddr = txtAddr.Text.Trim
Else
.ClientRegOfficeAddr = txtRegOffice.Text.Trim
End If
.MailtoCorresAddr = RBtnCorresAddr.Checked
.MailtoRegOffice = RBtnRegOffice.Checked
.ClientHPhone = mskHandPhone.Text.Trim
.ClientPager = mskPagerNo.Text.Trim
.ClientTel = mskTelephone.Text.Trim
.ClientFaxNo = mskFax.Text.Trim
.ClientEmail = txtEmail.Text.Trim
.PrimaryPartner = txtPriPartner.Text.Trim
.SecondPartner = txtSecPartner.Text.Trim
.BroughtInBy = cboPreferredBy.Text.Trim
.PersonIncharge = cboPersonIncharge.Text.Trim
.GLAC = cboGLAcode.Text.Trim
.ContactPerson = txtContactPerson.Text.Trim
.AcraNo = txtAcraNo.Text.Trim
.Active = chkActive.Checked
If dtpfyear.Checked = True Then
.YearEnd = dtpfyear.Text
End If
.DeptNo = cboDeptNo.Text.Trim
.DateJoined = dtDateJoined.Value
If cboClientName.SelectedIndex = -1 Then
.Group = txtClientNo.Text
Else
.Group = cboClientName.SelectedValue
End If
.GroupStatus = RButtonMainYes.Checked
.MainGroup = RButtonSubYes.Checked
If IsDate(dtIncorporationDate.Text) Then
.DateOfIncorporation = dtIncorporationDate.Text
Else
.SetDateOfIncorporationNull()
End If
End With
ObjDRow.EndEdit()
ClientTableAdapter.Update(DataDataSet.Client)
Error is occurs when ClientTableAdapter Update.
This error occurs for some client only.
I already check datatype of database and table adapter's datatype and all datatype are same.
My input value datatype and table adapter's datatype are same.
This error occurs even I command all line of update code (.ClientName to last line) but this error still occurs.WTF
Most answers say this is a single quote problem but In my case, There is no single quote.
All data types are same and input values are the same with datatype.
** Updated**
This error still occurs even I do like=>
ObjDRow = DataDataSet.Client.Rows.Find(strClientNo)
ObjDRow.EndEdit()
ClientTableAdapter.Update(DataDataSet.Client)
There is nothing change just select and update.
But if I remove ObjDRow.EndEdit().All are fine. There is no error.

Related

Cannot update SQL Boolean value

For my toggle of a Boolean value with Flask and SQLite I want to change 1 into 0 and 0 into 1 on table engineering_project. The message can be successfully flashed so the if function is working. However, the value of engg_proj_status in the table cannot be updated:
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
c = conn.cursor()
c.execute("SELECT engg_proj_status FROM engineering_project WHERE engg_proj_id =?",(engg_proj_id,))
status = c.fetchone()[0]
if status == 1:
c.execute("UPDATE engineering_project SET engg_proj_status = ? WHERE engg_proj_id = ?;",(False,engg_proj_id))
flash("Status changed from COMPLETED to OPEN")
else:
c.execute("UPDATE engineering_project SET engg_proj_status = ? WHERE engg_proj_id = ?;",(True,engg_proj_id))
flash("Status changed from OPEN to COMPLETED")
Add conn.commit()
Thanks to this comment from forpas.

how to access the string containing "=" and "AND" operator in where clause in oracle

My query is like but it' not working and giving error "SQL command not properly ended" and the string:HDR.TRX_DT = DTL.TRX_DT AND HDR.BU_TYPE = DTL.BU_TYPE AND HDR.BU_CODE = DTL.BU_CODE
AND HDR.TRX_NO = DTL.TRX_NO AND HDR.RGSTR_NO = DTL.RGSTR_NO AND HDR.TRX_TYP_CD in ('COS') is value in column . i want use that value in where clause of select statement .How will do you that .plz suggest
select * from mdbat.migration_ctrl_all where addition_condition='HDR.TRX_DT = DTL.TRX_DT AND HDR.BU_TYPE = DTL.BU_TYPE AND HDR.BU_CODE = DTL.BU_CODE
AND HDR.TRX_NO = DTL.TRX_NO AND HDR.RGSTR_NO = DTL.RGSTR_NO AND HDR.TRX_TYP_CD in ('COS')';
Escape the ' delimiting the COS string, as said by Alex Larionow. But escape each one with another '
select * from mdbat.migration_ctrl_all where addition_condition='HDR.TRX_DT = DTL.TRX_DT AND HDR.BU_TYPE = DTL.BU_TYPE AND HDR.BU_CODE = DTL.BU_CODE
AND HDR.TRX_NO = DTL.TRX_NO AND HDR.RGSTR_NO = DTL.RGSTR_NO AND HDR.TRX_TYP_CD in (''COS'')';

vb6 to vb.net for OracleInProcServer.OraDynaset

I am converting a project which is coded in old vb6 way. I am replacing the instances of OracleInProcServer.OraDynaset to Datatable for getting the data from database. But a form is generated in a dynamic way has the below code. i don't know how be there a alternate code for there in vb.net. Is there any way I can replace the below code without using dsAnswer As OracleInProcServer.OraDynaset. I don't know what is ! here also and how it is working.
Dim dsAnswer As OracleInProcServer.OraDynaset
Select Case dsAnswer!Shape.Value
Case 0 To 5
iShapes = iShapes + 1
'Load(f!shpCtrl(iShapes))
frmDynaForm.shpCtrl.Load(iShapes)
frmDynaForm.shpCtrl(iShapes).FillColor = System.Drawing.Color.FromArgb(DecodeColorDesc(Format$(dsAnswer!Color.Value)))
'frmDynaForm.shpCtrl(iShapes).Shape = dsAnswer!Shape.Value
frmDynaForm.shpCtrl(iShapes).Top = dsAnswer!Top.Value
frmDynaForm.shpCtrl(iShapes).Left = dsAnswer!Left.Value
frmDynaForm.shpCtrl(iShapes).Height = dsAnswer!Height.Value
frmDynaForm.shpCtrl(iShapes).Width = dsAnswer!Width.Value
frmDynaForm.shpCtrl(iShapes).BorderWidth = dsAnswer!BorderWidth.Value
frmDynaForm.shpCtrl(iShapes).Visible = True
Case -1
iLines = iLines + 1
'Load(f!lineCtrl(iLines))
frmDynaForm.lineCtrl.Load(iShapes)
frmDynaForm.lineCtrl(iLines).BorderColor = System.Drawing.Color.FromArgb(DecodeColorDesc(Format$(dsAnswer!Color.Value)))
frmDynaForm.lineCtrl(iLines).Y1 = dsAnswer!Top.Value
frmDynaForm.lineCtrl(iLines).X1 = dsAnswer!Left.Value
frmDynaForm.lineCtrl(iLines).Y2 = dsAnswer!Height.Value
frmDynaForm.lineCtrl(iLines).X2 = dsAnswer!Width.Value
frmDynaForm.lineCtrl(iLines).BorderWidth = dsAnswer!BorderWidth.Value
frmDynaForm.lineCtrl(iLines).Visible = True
End Select

Creating a multiple query

I would like to run 2 queries within the same code, but I cannot figure out how to. The 2 queries are as follows:
UPDATE usercomp
SET shiftstart = shifts.shiftstarttime,
shiftfinish = shifts.shiftfinishtime
FROM shifts
WHERE usercomp.shiftid = shifts.id
SET break1start = breaks.timestarted,
break1finish = breaks.timefinished,
break1duration = breaks.duration
FROM breaks
WHERE usercomp.break1id = breaks.id;
I am getting the following error:
ERROR: syntax error at or near "SET"
LINE 6: SET break1start = breaks.timestarted,
Can anyone help ?
You need to write two UPDATE statement
UPDATE usercomp
SET shiftstart = shifts.shiftstarttime,
shiftfinish = shifts.shiftfinishtime
FROM shifts
WHERE usercomp.shiftid = shifts.id;
UPDATE usercomp
SET break1start = breaks.timestarted,
break1finish = breaks.timefinished,
break1duration = breaks.duration
FROM breaks
WHERE usercomp.break1id = breaks.id;

Getting Error:Table variables and insert 'fieldnames' do not match. while exporting data from matlab to sql

I am getting the Error using database.jdbc.connection/fastinsert (line 140)
Table variables and insert 'fieldnames' do not match. error while exporting data from matlab to sql. Can you please help me out.
Below is my code.
conn = database('rScenariosDB','NCAT\aabhaler','','Vendor','Microsoft SQL Server','Server','A0030110GB6S942','AuthType','Windows','portnumber',1433);
for i = 1 : rScenarioCnt
if rScenario{i}.status == 1
ECostMax(i) = rScenario{i}.ECostMax;
CO2EmisMax(i) = rScenario{i}.CO2EmisMax;
ECost(i) = rScenario{i}.YearAlloc.ECost;
CO2Emis(i) = rScenario{i}.YearAlloc.CO2Emis ;
EmisCostYear(i) = rScenario{i}.YearAlloc.EmisCostYear ;
CO2EmisYear(i) = sum(rScenario{i}.YearAlloc.CO2EmisYear);
end
end
rId = 1 : rScenarioCnt ;
colnames={'rScenarioId' ,'ECostMax' , ' CO2EmisMax','ECost' ,'CO2Emis', 'EmisCostYear', 'CO2EmisYear' };
data = table(rId',ECostMax',CO2EmisMax',ECost',CO2Emis',EmisCostYear', CO2EmisYear','VariableNames',colnames);
tablename = 'rScenarios';
fastinsert(conn,tablename,colnames,data);
curs=exec(conn,'select * from [dbo].[rScenarios]');
curs=fetch(curs);
disp(curs.Data);
close(curs);
close(conn);