|
I agree on the use of Integer and Strings in a search not the best design.
Other searches where I use just one month and the year work fine.
FWIW if I search for Jan to Feb by not using Feb and use Mar instead I get the proper results
ie Jan & Feb data only. It is as if the rdr does not know when to stop reading ? ? ?
When the app loads this test runs.It is to find the 4 Tue of the month. Could it be interfering ?
Function FourthTueOfNextMonth(dt As Date) As Date
Dim currDate As Date = (New Date(dt.Year, dt.Month, 1)).AddMonths(1)
While currDate.DayOfWeek <> DayOfWeek.Tuesday
currDate = currDate.AddDays(1)
End While
Return currDate.AddDays(21)
End Function
I have looked at the DB with DB Browser all data looks fine
When I create the table I used this syntax
txSearchMonth TEXT)" same format for Year
Not sure changing to Numeric would solve the issue.
Thanks for the reply
|
|
|
|
|
I posted an Answer to my question. Tested on a few cases looks like it is a good solution.
Per your comment I will look at keeping all the variables as integers and not mixing in strings.
|
|
|
|
|
your observation made me wonder why I used string for year?
As I was writing a small test app it happened with strict ON I had a issue converting a INTEGER to a String
So I gave up and just made gvYear a string So you know I learned from my mistake
gvYear = Convert.ToInt32(tbYear.Text)
If you like you can look at my final solution here
Link to CP Question[^]
Thanks for the comment
|
|
|
|
|
After refreshing my brain with a long search through my SQL book I found this ANSWER
I have not used the SQL Syntax "IN" before but the key word and the addition of Parenthesis I have a solution.
Life is good
This is the faulty line of code
cmd.CommandText = "SELECT * FROM TxData WHERE txSearchMonth >= $gvFromMonth AND txSearchMonth <= $gvToMonth AND txYear = $gvYear "
This is the correct syntax below
cmd.CommandText = "SELECT * FROM TxData WHERE txSearchMonth IN ($gvFromMonth, $gvToMonth) AND txYear = $gvYear "
|
|
|
|
|
That changes the meaning of your query from "records between these two months (inclusive)" to "records in these two specific months".
But that doesn't address your question:
Quote: if I select Jan and Feb and enter the year my results includes the current month
NOT just January and February
There are no months between January and February, so the two queries are identical.
Unless there's something else odd about your data that you haven't told us?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
BACK to the drawing board DAM
Just did a search Jan to Mar and NO Feb data
You mean I need to know how to test ha ha
Might try adding my original >= IN <= parameters
If that fails Google search time
Thanks for the heads up advice
|
|
|
|
|
I'm facing a problem with VB.NET 2022 that I recently installed on my PC. I'm new to programming, so I'd appreciate some guidance on this issue.
The problem I'm encountering is related to the "Windows Form App" template in VB.NET 2022. Here's what's happening:
Initial Launch: When I launch VB.NET 2022 for the first time and create a new project using the "Windows Form App" template, everything works as expected. The form is displayed correctly.
Subsequent Launches: However, if I close VB.NET and reopen it, the "Windows Form App" template seems to be missing. It's not available in the list of project templates. This happens every time I close and reopen VB.NET.
Opening Previous Projects: Additionally, if I try to open a project that I created using the "Windows Form App" template, I encounter an error message.
I'm really eager to learn and get started with programming, so this issue is quite frustrating for me. As a beginner, I would greatly appreciate any assistance or guidance you can provide to help me resolve this problem.
Thank you so much for your time and help!
|
|
|
|
|
ionline4u wrote: if I try to open a project that I created using the "Windows Form App" template, I encounter an error message.
And what does this "error message" tell you?
|
|
|
|
|
i have seen the error message only one time and do not notice about the error.Now the designer is also disapear.I try to retrive the error message but this time the error message is also disapear.
|
|
|
|
|
Why is it every noob thinks the error message isn't important? IT'S THE ONE PIECE OF INFORMATION EVERYONE NEEDS TO TROUBLESHOOT THE PROBLEM!
I would recommend uninstalling Visual Studio and reinstalling it and see if you can get the error message again or it just works after that.
|
|
|
|
|
Because we are experienced we must have seen all error messages, and can guess which one the OP is talking about.
|
|
|
|
|
I assume that you are referring to Visual Studio 2022, as I do not think there is an application named VB.NET 2022. You should check that you have the Visual Basic workload correctly installed - use the "Extensions" -> "Manage Extensions" menu items. Also, check which template you are using: "Windows Forms App"* or "Windows Forms App (.NET Framework)". You can gather further information by examining the folders where your projects are being saved.
*The first of these use the new .NET core versions of the code and framework.
|
|
|
|
|
Generating a small printing program. I have Brother color laser printer that can duplex print. However, when I get the CanDuplex value, it returns False:
pd.PrinterSettings.CanDuplex
The interesting thing is that checking for color capability works just fine:
pd.PrinterSettings.SupportsColor
Accessing the printer via conventional MS Office applications (as well as other applications like Acrobat) has no problem identifying that the printer can print in duplex.
Thoughts?
Pound to fit, paint to match
modified 21-Aug-23 11:37am.
|
|
|
|
|
|
Please I am using VB.net 2019 and Sql 2016 and I have the below codes which inserts the pdf into the database successfully. But retrieving it becomes a problem for me and that is not the case for an image. I want to convert and retrieve this line of code into pdf "Me.Pdf1.Image=Image.fromStream(ms)" which gives an exception because it is not an image but pdf in the database. Please help me. Thank
OpenFileDialog1.ShowDialog()
txtPdfPath.Text = OpenFileDialog1.FileName
Dim ms1 As New MemoryStream
frmBPA1.Pic1.Image.Save(ms1, frmBPA1.Pic1.Image.RawFormat)
SqlQuery = "Insert into BPA1 (Pdf1)Values(@Pdf1)"
com.Parameters.AddWithValue("@Pdf1", ms1.ToArray)
com.CommandText = SqlQuery
com.CommandType = CommandType.Text
SQLCon.Open()
com.ExecuteNonQuery()
SQLCon.Close()
Dim strQuery As String = "Select df1 from BPA1"
SQLCon1.Open()
comFile = New SqlCommand(strQuery, SQLCon1)
comFile.Parameters.AddWithValue("@ReceiptNo", Me.txtReceiptNo.Text.Trim)
daFile = New SqlDataAdapter(comFile)
daFile.Fill(taFile)
If taFile.Rows(0).Item("Pic1") IsNot DBNull.Value Then
Dim img() As Byte
img = taFile.Rows(0).Item("Pdf1")
Dim ms As New MemoryStream(img)
If img.Length <> "0" Then
Me.Pic1.Image = Image.FromStream(ms)
End If
|
|
|
|
|
txtPdfPath.Text = OpenFileDialog1.FileName
That is not uploading anything, OpenFileDialog gets filenamse from the uiser, but it does not read them.
frmBPA1.Pic1.Image.Save(ms1, frmBPA1.Pic1.Image.RawFormat)
SqlQuery = "Insert into BPA1 (Pdf1)Values(@Pdf1)"
You create a memory stream object ms1 from some image data. You then try to save something that you have saved in the variable named Pdf1 , but you have not placed any data in Pdf1 that I can see. And why are you treating a PDF file as image data?
|
|
|
|
|
Thanks for the reply. Please storing the pdf is not a problem but retrieving it is issue for now. Please how do I retrieve this line Me.Pic1.Image = Image.FromStream(ms) and convert it into pdf. This line of code was used to retrieve image file correctly and I used the same process to store a pdf file but the above code to retrieve is it is the problem. Thanks
Dim strQuery As String = "Select ReceiptNo,Pic1 from BPA1 where ReceiptNo=@ReceiptNo"
SQLCon1.Open()
comFile = New SqlCommand(strQuery, SQLCon1)
comFile.Parameters.AddWithValue("@ReceiptNo", Me.txtReceiptNo.Text.Trim)
daFile = New SqlDataAdapter(comFile)
daFile.Fill(taFile)
If taFile.Rows(0).Item("Pic1") IsNot DBNull.Value Then
Dim img() As Byte
img = taFile.Rows(0).Item("Pic1")
Dim ms As New MemoryStream(img)
If img.Length <> "0" Then
Me.Pic1.Image = Image.FromStream(ms)
Else
Me.Pic1.Image = Nothing
End If
End If
|
|
|
|
|
If you cannot retrieve the PDF data then how can you be sure that you have saved it correctly? As I mentioned in my previous response, I cannot see any PDF data being saved.
|
|
|
|
|
That demonstrates a misunderstanding of what a PDF is.
To view an image such as a png you use an image viewer that supports png images. To view a PDF you use a PDF viewer. Those are two different things.
Your thought process should be - first section.
1. Find the file (it does not matter that it is a PDF.)
2. Store the bytes in the file as binary/raw in the database. At this point it is not actually a PDF (and certainly not an image), but rather just binary/raw data.
Second section
1. Load the binary data
2. Handle the binary data as a PDF file. Such as figuring out how to either use a PDF viewer or deferring to something (like browser).
From the above this means that the following code is always going to be wrong. Because it is not an image.
Image.FromStream(ms)
|
|
|
|
|
How to access scanner device in vb?
|
|
|
|
|
This question can only be answered with the documentation of this device and perhaps additional information from the distributer.
|
|
|
|
|
|
<pre>Hi, i am quit new to .net. But this should be easy for you guys
the output of a string is 202205W24 or 202205W1
I want the last digit so 24 or 1 from the string and use those digits as a string</pre>
|
|
|
|
|
|