|
To be honest I don't think anyone is teaching them, I remember when I was learning I stored dates as text, I then discovered the data type, that was in the 80s mind you. If these people are just diving in to build some hobby app without ever having done any reading I would expect these questions.
The seriously frightening thing is they may have been taught!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes I do not have any training in vb.net. I am trying to lean it on my own, as the courses here in south Africa is very expensive.
Where must the date be not string/text, I don’t understand where I should change it.
|
|
|
|
|
I have a web-server and my database is MySQL in Xampp so I want to use VB 2008 to connect MySQL in XAMPP 1.7 by internet online ..help me please
|
|
|
|
|
manoph wrote: I have a web-server and my database is MySQL in Xampp so I want to use VB 2008 to connect MySQL in XAMPP 1.7 by internet online I assume that you're talking about an ASP.NET application, not a WinForm app. Wouldn't XAMPP be more suited for PHP-development, as opposed to hosting ASP.NET apps?
You'll need a webserver that's capable of serving ASP.NET pages; those will connect to the MySQL in your XAMPP stack. The webserver needs to be accessible from outside of the network; meaning that you'll need to setup your firewall and router to accept incoming traffic. If you're doing this on an ADSL-line from home, look at the NAT-settings of the router.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks you for your advise
|
|
|
|
|
You're welcome
|
|
|
|
|
Hi,
I am trying to generate a report with Crystal Report.
But my report is blank
My code is ...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
OpenConnection()
qry = "SELECT * FROM customer"
dbcommand.Connection = DbConn.conn
dbcommand.CommandText = qry
dbadapter.SelectCommand = dbcommand
dbadapter.Fill(stdata, "Customer")
Dim objRpt As New CustomerRpt
objRpt.SetDataSource(stdata.Tables("Customer"))
rptViewer.ReportSource = objRpt
rptViewer.RefreshReport()
Catch ex As Exception
MsgBox(ex.Message)
Finally
CloseConnection()
End Try
End Sub
The Customer table has 7 rows.
I am using mysql database and vb.net 2010.
One more thing I would like to inform you that, while designing the CrystalReport, I did not find any field in CrystalReport --> Field Explorer --> Database fields
|
|
|
|
|
Put a breakpoint and then examine stdata.Tables right after you call fill.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have created a class which when instantiated, creates a SQL connection, SQL command, etc.
By repeatedly calling some methods it processes data using that one connection and SQL command.
When I'm done with this object, shouldn't I close/dispose of my SQL connection and command?
Should I do this by implementing Dispose() ?
Or
Should I create a method within my class called,"CleanUp" and just release the SQL connection and command there.
Also, I have a few Dictionaries and Lists in this class; should I ".Clear" them also ?
Maybe I should just set "myObject = Nothing" in my calling application?
Your guidance is appreciated.
|
|
|
|
|
If your class owns references to disposable objects, it should implement IDisposable to dispose of those references.
Providing a public method with a different name has no benefit; you won't be able to wrap your class in a Using block, and developers using your class might not even realise that they have to call your SpecialSnowflakeCleanUp method when they've finished with an instance of your class. If your class implements IDispoable , it's a clear indication that it requires clean-up.
There's no need to clear collections or references to managed objects; you only need to worry about unmanaged references and disposable objects.
Implementing IDisposable and the Dispose Pattern Properly[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hmmm ... Based on your suggestions, I am going to refactory my code.
|
|
|
|
|
Hello All,
I want to make a Label that I can drag and drop. At the same time when I drag the original label it will leave a copy of it self.
Example: When I drag Label1 it will leave another Label to its Original Position( Lets Name the New Label1 in Original Position as Label2),
Then I should also be able to drag Label2 and Leave another Label (Label3), I also want to drag Label1 and Label2 but it should not leave a copy.
Here is my code: I been able to do multiplication of Label and Dragging of Label but I cannot drag all Labels:
Public Class Form1
Dim cursorX, cursorY As Integer
Dim dragging As Boolean
Dim labelno As Integer = 1
Private Sub Control_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
dragging = True
cursorX = e.X
cursorY = e.Y
Dim label2 As New Label
labelno += 1
label2.Location = New Point(Label1.Location.X, Label1.Location.Y)
label2.Name = "Label" + labelno.ToString
label2.Text = label2.Location.ToString
Me.Controls.Add(label2)
End Sub
Private Sub Control_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp
dragging = False
End Sub
Private Sub control_MouseMOve(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
If dragging Then
Dim ctrl As Control = CType(sender, Control)
ctrl.Left = (ctrl.Left + e.X) - cursorX
ctrl.Top = (ctrl.Top + e.Y) - cursorY
ctrl.BringToFront()
End If
End Sub
If you have clarification please inform me.
Thanks
|
|
|
|
|
You don't put the dragging code for a Label in the Form. You create your own Label control and put the dragging code in there. That makes your Label reusable in any control that has a Controls collection, such as a Form or Panel or whatnot.
I wrote up an article to do this very thing about 7 years ago and it's still valid today. Read: Create your Own Runtime Movable Windows Forms Controls[^]
|
|
|
|
|
Hi,
I know my question is a bit old and many people asked about this.
I would like to tell you that, I searched my question in various forums and also google it but I did not find my exact answer.
Somewhere it is written "Multiple column combobox" and somewhere it is written "Autocomplete combobox". But I found nowhere about "Multiple column autocomplete combobox".
-----------------------------
| ARIZONA | \/ | <-- Autocomplete Combobox (Autocompletemode = Suggest)
---------------------------------------------------------
| ARIZONA | 16 | D16 |
| ALBAMA | 18 | A28 | <-- 3 Column Dropdown
| ALASKA | 12 | C34 |
---------------------------------------------------------
I just need the above type autocomplete combobox where the data comes from a mysql database table. And how to implement it in datagridview.
I tried it in a combobox.....
Private Sub LoadCombo()
Dim dcommand As New MySqlCommand
Dim dadapter As New MySqlDataAdapter
Dim stdata As New DataTable
qry = "SELECT * FROM statedetails"
Try
OpenConnection()
dcommand.Connection = conn
dcommand.CommandText = qry
dadapter.SelectCommand = dcommand
dadapter.Fill(stdata)
Dim dbreader As MySqlDataReader = dcommand.ExecuteReader
While dbreader.Read
For i = 0 To stdata.Rows.Count - 1
cmb.Items.Add(stdata.Rows(i).Item("State"))
cmb.Items.Add(stdata.Rows(i).Item("OfficeId"))
cmb.Items.Add(stdata.Rows(i).Item("CityId"))
Next
cmb.DisplayMember = "State"
cmb.ValueMember = "StateId"
End While
cmb.AutoCompleteMode = AutoCompleteMode.Suggest
cmb.AutoCompleteSource = AutoCompleteSource.CustomSource
Catch ex As Exception
MsgBox(ex.Message)
Finally
CloseConnection()
End Try
End Sub
but the result is
-----------------------
| ARIZONA | \/ | <-- Autocomplete Combobox (Autocompletemode = Suggest)
-----------------------
| ARIZONA |
|16 |
|D16 |
| ALBAMA |
|18 | <-- 1 Column Dropdown
|A28 |
| ALASKA |
|12 |
|C34 |
-----------------
.... and autocomplete not happening.
I also want to do that, if I select Arizona, the Datagridview nex t cell will populate data "16" ("OfficeId").
I found the link...
Flat-MultiColumn Combobox with Autocomplete[^]
but this is a bit complex to me.
My question is how should I implement it in a combobox and in datagridview combobox ?
Please help...
modified 24-Jul-13 1:56am.
|
|
|
|
|
Biplob Singha Shee wrote: My question is how should I implement it in a combobox and in datagridview combobox ? A datagridview doesn't come with autocomplete, and comboboxes aren't grids. Which column should it use for the autocomplete if the user starts typing away?
Biplob Singha Shee wrote: but this is a bit complex to me. Then it might be a better idea to slam a datagridview on a form, add a textbox on bottom, write your own "autocomplete" (just lookup the value of the textbox in the grids' datasource) and pop that up when (without borders) if the user presses the button.
Yes, might be a bit work, but the design would be simpeler and the time required to develop it might even be less than trying to figure out how to tame a combobox.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Very thanks... I am trying...
|
|
|
|
|
Hi,
I am using vb.net form Reportviewer control which is calling .RDLC file but I want to pass two parameter toDate and fromDate to the report. I tried many option but no luck yet. can anyone please help.... below is the code options I have used..
Imports Microsoft.Reporting.WinForms
Public Class frmGuestPassReport
Private Sub frmGuestPassReport_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'GuestPassDS.GuestPass_Transaction' table. You can move, or remove it, as needed.
Me.GuestPass_TransactionTableAdapter.Fill(Me.GuestPassDS.GuestPass_Transaction)
Me.ReportViewer1.RefreshReport()
Me.ReportViewer1.RefreshReport()
Me.ReportViewer1.RefreshReport()
End Sub
'Private Sub FillByToolStripButton_Click(sender As System.Object, e As System.EventArgs)
' Try
' Dim RP(1) As Microsoft.Reporting.WinForms.ReportParameter
' RP(0) = New Microsoft.Reporting.WinForms.ReportParameter("fromDate", "2013-07-17")
' RP(1) = New Microsoft.Reporting.WinForms.ReportParameter("toDate", "2013-07-18")
' Me.GuestPass_TransactionTableAdapter.FillBy(Me.elevateDataSet.GuestPass_Transaction, FromDateToolStripTextBox.Text, ToDateToolStripTextBox.Text)
' Me.ReportViewer1.LocalReport.SetParameters(RP)
' Me.ReportViewer1.RefreshReport()
' Catch ex As System.Exception
' System.Windows.Forms.MessageBox.Show(ex.Message)
' End Try
'End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)
'Dim adapter As New GuestPassDSTableAdapters.GuestPass_TransactionTableAdapter()
'Dim table As New GuestPassDS.GuestPass_TransactionDataTable()
'adapter.FillBy(table, Format(CDate(dtFromDate.Text.Trim), "yyyy-MM-dd"), Format(CDate(dtToDate.Text.Trim), "yyyy-MM-dd"))
'Dim myNewSource As New ReportDataSource("dsGuestPass", CType(table, DataTable))
'Me.ReportViewer1.LocalReport.DataSources.Clear()
'Me.ReportViewer1.LocalReport.DataSources.Add(myNewSource)
'Me.ReportViewer1.LocalReport.Refresh()
'Me.ReportViewer1.RefreshReport()
Try
Dim adapter As New GuestPassDSTableAdapters.GuestPass_TransactionTableAdapter()
Dim table As New GuestPassDS.GuestPass_TransactionDataTable()
adapter.FillByDate(table, Format(CDate(fromDate.Text.Trim), "yyyy-MM-dd"), Format(CDate(toDate.Text.Trim), "yyyy-MM-dd"))
Dim pInfo As ReportParameterInfoCollection
Dim paramList As New Generic.List(Of ReportParameter)
Dim sfdate As String = Format(fromDate.Value, "yyyy-MM-dd")
paramList.Add(New ReportParameter("fromDate", sfdate, False))
Dim stdate As String = Format(toDate.Value, "yyyy-MM-dd")
paramList.Add(New ReportParameter("toDate", stdate, False))
ReportViewer1.LocalReport.SetParameters(paramList)
pInfo = ReportViewer1.LocalReport.GetParameters()
Me.ReportViewer1.RefreshReport()
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
'Me.ReportViewer1.LocalReport.DataSources.Clear()
'Dim adapter As New GuestPassDSTableAdapters.GuestPass_TransactionTableAdapter()
'Dim table As New GuestPassDS.GuestPass_TransactionDataTable()
'adapter.FillByDate(table, Format(CDate(fromDate.Text.Trim), "yyyy-MM-dd"), Format(CDate(toDate.Text.Trim), "yyyy-MM-dd"))
'Dim myNewSource As New ReportDataSource("dsGuestPass", CType(table, DataTable))
'Me.ReportViewer1.LocalReport.DataSources.Add(myNewSource)
'Me.ReportViewer1.Show()
'Me.ReportViewer1.LocalReport.Refresh()
'Me.ReportViewer1.RefreshReport()
ReportViewer1.ProcessingMode = ProcessingMode.Local
ReportViewer1.LocalReport.ReportPath = "GuestPassTransaction.rdlc"
Dim adapter As New GuestPassDSTableAdapters.GuestPass_TransactionTableAdapter()
Dim table As New GuestPassDS.GuestPass_TransactionDataTable()
adapter.FillByDate(table, Format(CDate(fromDate.Text.Trim), "yyyy-MM-dd"), Format(CDate(toDate.Text.Trim), "yyyy-MM-dd"))
Dim pInfo As ReportParameterInfoCollection
Dim paramList As New Generic.List(Of ReportParameter)
Dim sfdate As String = Format(fromDate.Value, "yyyy-MM-dd")
paramList.Add(New ReportParameter("fromDate", sfdate, False))
Dim stdate As String = Format(toDate.Value, "yyyy-MM-dd")
paramList.Add(New ReportParameter("toDate", stdate, False))
ReportViewer1.LocalReport.SetParameters(paramList)
pInfo = ReportViewer1.LocalReport.GetParameters()
Me.ReportViewer1.RefreshReport()
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
End Class
Thanks,
dfdff
|
|
|
|
|
When using an RDLC we get the data first and pass that to the report viewer along with the report. This is the code from an old winforms sample passing in the datatable and the name of the report file
public partial class frmViewer : Form
{
public frmViewer(string sReportFile, DataSet dsData)
{
InitializeComponent();
ReportFile = sReportFile;
ReportDataSet = dsData;
}
private string ReportFile { get; set; }
private DataSet ReportDataSet { get; set; }
private void Form1_Load(object sender, EventArgs e)
{
string sPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Reports";
ReportDataSet.Tables[0].TableName = "dtReport";
ReportDataSet.DataSetName = "ReportData";
string RepResource = Path.Combine("D:\\Bin10\\Reports\\Reports\\Reports", ReportFile + ".rdlc");
repViewer.Reset();
repViewer.LocalReport.ReportEmbeddedResource = RepResource;
repViewer.LocalReport.DataSources.Add(new ReportDataSource("ReportData", ReportDataSet.Tables[0]));
this.repViewer.RefreshReport();
}
}
Note that you need to name the table the same as the datasource used when designing the report.
[edit] sorry the sample is in c# but I no longer use VB [/edit]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Thanks for replying..but my question was how to pass report parameter...
dfdff
|
|
|
|
|
Here is one way your could do it.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim params As New List(Of Global.Microsoft.Reporting.WinForms.ReportParameter)
For Each pi As Microsoft.Reporting.WinForms.ReportParameterInfo In ReportViewer1.LocalReport.GetParameters()
Dim values() As String = pi.Values.ToArray()
Select Case pi.Name
Case "FromDate"
SetParameterValue_0(values, Today.ToString())
Case "ToDate"
SetParameterValue_0(values, Today.AddDays(1.0#).ToString())
End Select
params.Add(New Microsoft.Reporting.WinForms.ReportParameter(pi.Name, values))
Next
ReportViewer1.LocalReport.SetParameters(params)
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub SetParameterValue_0(ByRef values() As String, ByVal value As String)
If values.Length = 0 Then
values = New String() {value}
Else
values(0) = value
End If
End Sub
|
|
|
|
|
Is there a way in VB6 to output an Access 2000 report to pdf?
|
|
|
|
|
Now there is a mix of ancient tech. Presumably you are using VB6 as the UI and Access as the DB. You may be able to save the report to excel and then convert it to PDF from there.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Or just install a PDF printer and print it from Access.
|
|
|
|
|
Hi,
I'm using a streamreader and writer for editing an excel vbaproject.bin file.
However when I read and write the file I have some differences in the codepage I think.
look at the pictures for what I mean[^]
At the left it is OK. After writing it's no longer ok (at the right)
Can some tell me what I'm doing wrong?
the code for reading
Dim s As New StreamReader(fiTemp.FullName, System.Text.Encoding.ASCII)
Dim vba As String = s.ReadToEnd()
s.Close()
The code for writing:
Dim s1 As New StreamWriter(fiTemp.FullName, False, System.Text.Encoding.ASCII)
s1.Write(newvba)
s1.Close()
I also tried without encoding
Jan
|
|
|
|
|
What's the VBA code you're using to read/write the file.
From the pictures, it appears as though you're trying to read/write a binary file and your VB.NET code is treating it as a text file. There is no encoding on a binary file.
|
|
|
|
|