|
At this rate, you're better off composing this query in Access itself; using its query designer.
THEN, you might use the SQL it generated (though creating a temporary Access table is probably better, in your case).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
same error comes up at below too, whats mistake here in syntax ?
Private Sub RetrieveData(Optional ByVal blnSearch As Boolean = False)
strSQL = " SELECT tblContact.ContactPK, tblContact.Fullname, tblContact.Nickname, tblContact.Mobile, " &
" tblContact.Phone, tblContact.eMail, tblContact.FacebookID, tblContact.PictureName, tblContact.Note, tblContact.Mobil, tblContact.Area, tblContact.City, tblContact.State, tblContact.Country, tblContact.Responsible, " &
" tblPosition.PositionName, tblDepartment.DepartmentName " &
" FROM [tblPosition] INNER JOIN (tblDepartment INNER JOIN tblContact ON " &
" tblDepartment.DepartmentPK = tblContact.DepartmentFK) ON tblPosition.PositionPK = tblContact.PositionFK "
'// blnSearch = True for Search
If blnSearch Then
strSQL = strSQL &
" WHERE " &
" [Fullname] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [Nickname] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [PositionName] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [DepartmentName] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [Mobile] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [Phone] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [eMail] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [FaceBookID] " & " Like '%" & txtSearch.Text & "%'" &
" [Mobil] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [Area] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [City] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [State] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [Country] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" [Responsible] " & " Like '%" & txtSearch.Text & "%'" & " OR " &
" ORDER BY ContactPK "
Else
strSQL = strSQL & " ORDER BY ContactPK "
End If
'
Try
Cmd = New OleDbCommand
If Conn.State = ConnectionState.Closed Then Conn.Open()
Cmd.Connection = Conn
Cmd.CommandText = strSQL
Dim DR As OleDbDataReader = Cmd.ExecuteReader
Dim i As Long = dgvData.RowCount
While DR.Read
With dgvData
.Rows.Add(i)
.Rows(i).Cells(0).Value = DR.Item("ContactPK").ToString
.Rows(i).Cells(1).Value = DR.Item("Fullname").ToString
.Rows(i).Cells(2).Value = DR.Item("Nickname").ToString
.Rows(i).Cells(3).Value = DR.Item("PositionName").ToString
.Rows(i).Cells(4).Value = DR.Item("DepartmentName").ToString
.Rows(i).Cells(5).Value = DR.Item("Mobile").ToString
.Rows(i).Cells(6).Value = DR.Item("Phone").ToString
.Rows(i).Cells(7).Value = DR.Item("eMail").ToString
.Rows(i).Cells(8).Value = DR.Item("FaceBookID").ToString
.Rows(i).Cells(9).Value = DR.Item("PictureName").ToString
newFileName = DR.Item("PictureName").ToString
.Rows(i).Cells(10).Value = DR.Item("Note").ToString
.Rows(i).Cells(11).Value = DR.Item("Mobil").ToString
.Rows(i).Cells(12).Value = DR.Item("Area").ToString
.Rows(i).Cells(13).Value = DR.Item("City").ToString
.Rows(i).Cells(14).Value = DR.Item("State").ToString
.Rows(i).Cells(15).Value = DR.Item("Country").ToString
.Rows(i).Cells(16).Value = DR.Item("Responsible").ToString
End With
i += 1
End While
lblRecordCount.Text = "[total : " & dgvData.RowCount & " record]"
DR.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'//
txtSearch.Clear()
End Sub
|
|
|
|
|
Missing OR on line
" [FaceBookID] " & " Like '%" & txtSearch.Text & "%'" &
Also you end the where clause with an additional OR
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
|
Take Note of Richards reply, not only will you application be safer, and that is a VERY serious issue, but these string structure problems will disappear.
To give you an idea if I (or any competent development manager) saw that code I would immediately reject the application.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
thank you so much, I will follow the advice.
|
|
|
|
|
HI.
I am building a race simulator using outputs from the iRacing SDK. Most outputs are straightforward but some (described in documentation as "FLOAT" are giving me the error: "Value of type 'iracingsdkwrapper.telemetryvalue(of single)'cannot be converted to integer."
I've tried all kinds of things including extensions but nothing gets a useable number from these types of values.
A typical output using .tostring shows the output as -0.0123456 rad
If I try to use Cint(), I get an error:
"An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation."
I'm using VB.NET through VS2012 Express.
Any help would be greatly appreciated.
Mike.
|
|
|
|
|
Why are you trying to convert such values into integers? The resulting numbers are unlikely to be of any use, as they lose most of their precision. The value -0.0123456 rad looks like an angle, so converting that to an integer will give you -0 which probably is not much use.
|
|
|
|
|
The particular parameter I'm looking at right now is the value for body roll which is, as you say, measured in rads.
The value as generated by the simulator is far too low to use but simply multiplying the value before converting would give me numbers that could safely be translated to integers.
Although the output is very precise, I only need approximate values as they will be mixed in with lateral acceleration, suspension deflection and some other values so any inaccuracies will be lost in the mix so to speak.
I just want a number that I can work with!
|
|
|
|
|
For such a small starting value you need to multiply by 100 or 1000 at least, I would guess.
|
|
|
|
|
That is my intention.
I currently do the same with the Lateral acceleration values which works fine. As would this, if I could get a useful number to start from.
|
|
|
|
|
How to retrieve the data from table and put in textbox
|
|
|
|
|
We will need a lot more information than this in order to help you. Post the code you have already tried and tell us what the problem is
|
|
|
|
|
|
This solved my problem:
Dim szF As SizeF = gr.MeasureString(Me.Text.Substring(0, iIndex), Me.Font, New SizeF(999, 999), StringFormat.GenericTypographic)
I have a control derived from UserControl in which I am trying to implement like a TextBox
and I am having trouble setting the caret in the correct text column position. Below is the
code to calculate the x offset and move the caret.
Simple test:
With the text "aBc", when I try to set the caret between 'a' and 'B' (iIndex=1), the caret is displayed
almost at the end of the 'B'.
MeasureDisplayStringWidth() is test code I found on the internet and
does not make any difference than using gr.MeasureString().
SetCaretPos() is the standared Windows API for setting the caret.
And for those who wonder why I don't just use a TextBox, this control has all kinds of custom
stuff including rotation.
I would appreciate any help.
Thank you
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim sb As SolidBrush = New SolidBrush(Color.FromArgb(255, 0, 0, 255))
' Display text
e.Graphics.DrawString(Me.Text, me.Font, sb, 0, 0)
End Sub
Private Sub MoveCaret(ByVal iIndex As Integer)
Dim gr As Graphics = Me.CreateGraphics()
' Both of these give the same result.
'Dim szF As SizeF = gr.MeasureString(Me.Text.Substring(0, iIndex), Me.Font)
Dim i As Integer = MeasureDisplayStringWidth(gr, Me.Text.Substring(0, iIndex), Me.Font)
gr.Dispose()
gr = Nothing
' Windows api call
MyUtilsLib.WindowsAPI.SetCaretPos(i, 1)
End Sub
Public Function MeasureDisplayStringWidth(ByVal gr As Graphics, ByVal text As String, ByVal fnt As Font) As Integer
If text.Length < 1 Then Return 0
Dim format As System.Drawing.StringFormat = New System.Drawing.StringFormat()
Dim rect As System.Drawing.RectangleF = New System.Drawing.RectangleF(0, 0, 1000, 1000)
Dim ranges As System.Drawing.CharacterRange() = {New System.Drawing.CharacterRange(0, text.Length)}
Dim regions As System.Drawing.Region() = {New System.Drawing.Region()}
format.SetMeasurableCharacterRanges(ranges)
regions = gr.MeasureCharacterRanges(text, fnt, rect, format)
rect = regions(0).GetBounds(gr)
Return CInt(rect.Right + 1.0F)
End Function
-- modified 28-Feb-19 15:15pm.
|
|
|
|
|
Not sure if this is the right place to post this.
My VB Winform app works on Win 7 32 bit just fine, and in VS 2017 when developing on my Win10 X64 machine. But when I go to install the app on my machine, it won't access or read the database files. There's no error or exception thrown. It worked before, up until perhaps last December.
Some research suggested that I need the Access Database Engine. So I did download that and installed but no difference. Not really sure which direction to go here. Perhaps I just need to add a file to my Wix installer program. I'm thinking it's the System.Data file that contains OLEDB and I can just add that to the install.
I do have my Wix installer set to X86, because the customer target machines are Win 7 32 bit. But I'm will be selling the new computers that are Win10 X64 so I need to fix this.
Any help or knowledge would be appreciated.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I changed the compile to X86, and choose Debug-Net4.0 and that version works
Tried Release-Net4.0 and that version didn't work
So the debug version works, but not the release
In release mode I get this error - The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine
Oh, I spent many hours working with nLog and integrated it into my windows apps. Just dawned on me to use my logging system to check for errors, Homer Simpson Duh!!!!!
I think I got this now ...
If it ain't broke don't fix it
Discover my world at jkirkerx.com
modified 26-Feb-19 14:47pm.
|
|
|
|
|
|
Message Closed
modified 11-Feb-19 12:17pm.
|
|
|
|
|
Doing so has huge problems. First, if the network connection to where you store the XLAM file goes down, the extension no longer works.
Next, if you screw up the code in the XLAM and put it in the stored location, you break it for EVERYONE.
And, if your code uses COM-based components, you have to install the thing the components anyway because you have to write the registry information used to tell the machine where to find the components and how to run them.
Do yourself, and your customers, a favor and just copy it locally, a.k.a.: install it.
As someone who repackages and deploys software as my primary job, running code from a network share is ROYAL PAIN IN THE ASS!
|
|
|
|
|
Hi Dave,
Thanks for your reply.
Sorry did not noticed your reply so deleted the question posted.
Sorry for deleting the post added.
Thanks
Manju
|
|
|
|
|
Hi Team,
I am trying to split the cells if comma and space .
I tried below code.Its spliting for space now.
How can i change it so that it will check for multiple(both space and comma)
Dim splitvals As Variant
Dim totalVals As Long
Set sh1 = ThisWorkbook.Sheets(1)
Set sh2 = ThisWorkbook.Sheets(2)
sh2.Cells.Clear
lrow1 = sh1.Range("A65356").End(xlUp).Row
For j = 2 To lrow1
splitvals = Split(sh1.Cells(j, 2), " ")
For i = LBound(splitvals) To UBound(splitvals)
lrow2 = sh2.Range("B65356").End(xlUp).Row
lrow3 = sh2.Range("A65356").End(xlUp).Row
sh2.Cells(lrow3 + 1, 1) = sh1.Cells(j, 1)
sh2.Cells(lrow3 + 1, 2) = splitvals(i)
Next i
Next j
Even i tried:
splitvals = Split(sh1.Cells(j, 2), ", " " ")
Please suggest me .
Thanks
Manju
|
|
|
|
|
Most method calls operate on objects, but your Split call does not appear to be connected to any object. Where is the documentation for that method?
|
|
|
|
|
Dim splitvals As Variant
Dim totalVals As Long
Dim myData As Workbook
Set myData = Workbooks.Open("D:\Test.xlsx")
Set sh1 = myData.Sheets(1)
Set sh2 = myData.Sheets(2)
sh2.Cells.Clear
lrow1 = sh1.Range("A65356").End(xlUp).Row
For j = 2 To lrow1
splitvals = Split(sh1.Cells(j, 2), ",")
For i = LBound(splitvals) To UBound(splitvals)
lrow2 = sh2.Range("B65356").End(xlUp).Row
lrow3 = sh2.Range("A65356").End(xlUp).Row
sh2.Cells(lrow3 + 1, 1) = sh1.Cells(j, 1)
sh2.Cells(lrow3 + 1, 2) = splitvals(i)
Next i
Next j
Thanks
Sharan
|
|
|
|
|
That is just a repeat of your question. I asked you where the Split method is defined.
|
|
|
|
|