Reputation: -1 Dishonored
- Active Members
- Active Posts:
- 118 (0.18 per day)
- 29-May 12
- Profile Views:
- Last Active:
- Feb 25 2014 11:46 AM
- Who Cares
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Dream Kudos:
Posts I've Made
Posted 20 Feb 2014hi,
where is this code? what method? also do not use On Error Resume Next. you should avoid using go to and specially on error resume next. what this do is that if error occurs the code do not stop and just resume with the lines below.
It's the mtbPin.TextLength = 15..
Anyways, I just found a solution which is mtbPin.MaskCompleted
Posted 19 Feb 2014@CharlieMay
Yup, that's what exactly I'm looking for before.. However I realized that I don't need to put A_I in receipt_no since
there are multiple items per receipt_no:
receipt number | Line number | SKU ---------------------------------- 123 1 987 123 2 456 123 3 345 111 1 135 111 2 888
If I put A_I on receipt_no it would be 123,124,125,126,127, etc.. But if not A_I then I would have to put the receipt_no manually, right? I can't think of a proper index for receipt_no..
Posted 19 Feb 2014May I ask why you chose the ADODB namespace instead of the In My Opinion, the much easier to use ADO.Net. It's just as compatible with MySQL.
You could actually save a lot of lines of code using ADO.Net.
There are a few tutorials here at DIC that would get you started, but I'm pretty sure that once you seen how easy it is to Add, Update, Delete and Query using the Data Access Objects that .Net offers you won't look back to the old "recordset/VB6" style of database access.
For example, let's look at a simple "Non-Query" execution method (INSERT, UPDATE or DELETE)
I'll use SQL server for this example, but switching it to MySQL is nothing more than renaming the objects
Dim con as New SQLConnection("your connection string") Dim sql as string "INSERT INTO ......." Dim cmd as New SQLCommand(sql, con) ' pass the INSERT statement and specify the connection con.Open cmd.ExecuteNonQuery con.Close cmd.Dispose
This same method can be use to execute an SQL of UPDATE MyTable.... or DELETE FROM MyTable.....
There is an additional step with Querying (SELECT <columns> FROM <table> .......) in that you need to instantiate a DataReader object. This is a collection of the rows returned from the SELECT statement that you can loop through to display the results returned.
Not to mention, you have easy access to the DataSet/DataTable objects that will make populating grids and allowing user changes to be persisted back to the actual database very easily.
Not what you're doing doesn't work, but since you're programming in .Net, why not take advantage of the power that the framework gives you.
And most importantly, remember, if you get stuck, we're here to help />
We weren't taught about using ADO.net yet that's why I'm using the recordset for our system projects to be submitted at school.
Anyhow, thanks for always suggesting me to use ADO.NET objects. I'll plan to use it after I finished these on-going projects. Very helpful indeed. Again, thanks!
Posted 19 Feb 2014I tried using this code to print my datagridview but the print results lacks a row. Also, when I attempt to print it again, all the row contents are being printed but lacks a row header..
Here's my code:
Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click PrintDialog1.Document = PrintDocument1 If PrintDialog1.ShowDialog = DialogResult.OK Then On Error Resume Next PrintDocument1.DefaultPageSettings.Landscape = True PrintDocument1.Print() End If End Sub Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim ReportFont As Font = New Drawing.Font("Calibri", 12) Dim HeaderFont As Font = New Drawing.Font("Calibri", 18) Dim drawBrush As New SolidBrush(Color.Black) ' Create pen. Dim blackPen As New Pen(Color.Black, 1) ' Create location and size of rectangle. Dim x As Integer = 0 Dim y As Integer = 0 Dim width As Integer = 420 Dim width2 As Integer = 250 Dim height As Integer = 20 ' Create points that define line. Dim point1 As New Point(50, 125) Dim point2 As New Point(1024, 125) ' Draw line to screen. e.Graphics.DrawString("PROSERV COMMUNICATION SYSTEMS", HeaderFont, drawBrush, 300, 50) e.Graphics.DrawString("U 11A G/F Century Plaza Bldg., 120 Peria St, Legaspi Vill., Makati City", ReportFont, drawBrush, 265, 75) e.Graphics.DrawString("AMELIA C. UGAY - Prop. ● VAT Reg. TIN 123-025-986-000", ReportFont, drawBrush, 285, 90) e.Graphics.DrawString("Tel Nos.: 893-1594/893-0898", ReportFont, drawBrush, 330, 105) e.Graphics.DrawLine(blackPen, point1, point2) With dgvInvoice Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit) fmt.LineAlignment = StringAlignment.Center fmt.Trimming = StringTrimming.EllipsisCharacter Dim y2 As Single = 375 Do While mRow < .RowCount Dim row As DataGridViewRow = .Rows(mRow) Dim x2 As Single = 50 Dim h As Single = 0 For Each cell As DataGridViewCell In row.Cells Dim rc As RectangleF = New RectangleF(x2, y2, cell.Size.Width, cell.Size.Height) e.Graphics.DrawRectangle(Pens.Black, rc.Left, rc.Top, rc.Width, rc.Height) If (newpage) Then e.Graphics.DrawString(dgvInvoice.Columns(cell.ColumnIndex).HeaderText, .Font, Brushes.Black, rc, fmt) Else e.Graphics.DrawString(dgvInvoice.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToString(), .Font, Brushes.Black, rc, fmt) End If x2 += rc.Width h = Math.Max(h, rc.Height) Next newpage = False y2 += h mRow += 1 If y2 + h > e.MarginBounds.Bottom Then e.HasMorePages = True mRow -= 1 newpage = True Exit Sub End If Loop mRow = 0 End With End Sub End Class
I don't know what's wrong with the code, when I read it line by line I think it's just fine.
Posted 19 Feb 2014You can set the column to autoincrement.. the database takes care of it from there.
Is it possible to set a starting number (for example: 10000) so that it wouldn't start with just "1" which
is very weird receipt number without inserting a starting value manually on database? I'm using phpmyadmin btw..
- Member Title:
- D.I.C Head
- Age Unknown
- Birthday Unknown