|
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.
|
|
|
|
|
|
Hi,
I have a MySql table.
Table Name : Rate
Fields:
1. CurrentDate
(DataType : Date )
2. MaterialPrice
(DataType : DOUBLE(10,3) )
In above everyday I have to enter the MaterialPrice as it changes everyday.
I created a form for the above table
I want to do that when my MdiForm loads, it checks if the Current Date data is blank and if it has no records then it open the form associated with the table(Rate).
I tried...
Private Sub FormMdi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim d As Date = Date.Today
qry = "SELECT * FROM Rate WHERE CurrentDate =" & d & ""
Try
OpenConnection()
Dim dbcommand As New MySqlCommand
dbcommand.Connection = conn
dbcommand.CommandText = qry
Dim dbread As MySqlDataReader = dbcommand.ExecuteReader
While (dbread.Read())
If dbread("CurrentDate") = "" Then
Dim f As New FormRate
f.Show()
f.Owner = Me
End If
End While
Catch ex As Exception
MsgBox(ex.Message)
Finally
CloseConnection()
End Try
End Sub
It not opening the form. While debugging it, I saw the control goes to
Finally
CloseConnection() directly from
While (dbread.Read()) but not firing
If dbread("CurrentDate") = "" Then
Dim f As New Rate
f.Show()
f.Owner = Me
End If and the formMdi opens.
My purpose not solved.
For your information, Table "Rate" is completely blank or has no records.
Please Help
modified 20-Jul-13 5:39am.
|
|
|
|
|
Sorry to disturb you...
I have got my solution...
|
|
|
|
|
Hi Everybody!
I've Problem when i click on label dlg.ShowDialog(), and here is my code
Private Sub LblCoCau_Err_Click(sender As System.Object, e As System.EventArgs) Handles LblCoCau_Err.Click
Dim newThread As New Thread(New ThreadStart(AddressOf ThreadMethod))
newThread.SetApartmentState(ApartmentState.STA)
newThread.Start()
End Sub
Private Shared Sub ThreadMethod()
Dim dlg As New OpenFileDialog()
dlg.ShowDialog()
MessageBox.Show(dlg.FileName)
End Sub
Error after click in lable lblCoCau_Err:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Please help me to resolve this issue. Thank's very much
|
|
|
|
|
Don't post a link to a screen-shot; use the "Copy exception detail to the clipboard" option and post the result.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Why are you creating a new thread just to show a dialog? Try it without and see what happens.
Use the best guess
|
|
|
|
|
You cannot create, show, nor touch in any way any UI items on anything other than the startup thread.
Creating a thread to show a modal dialog? That's completely pointless...
|
|
|
|
|
|
Okay so I'm very new to Encryption, I have done a lot of research via Google and I cannot find an answer to my questions, so either I'm totally not understanding this or .. okay I don't get it. Maybe someone here can help:
1. I need to generate a 256 bit Public / private key pair and store them for later use
2. I need to be able to encrypt using a stored private key
3. I need to be able to decrypt with a stored public key
(2 and 3) I was unable to find some example where keys are loaded from a file to be used, they all generated the keys new for each encryption.
And maybe someone can explain to me the way to encrypt and decrypt large files about 5 mb each with a loop, as the padding issue seems to have issues. Im trying to break up very lage files into 5mb chunks and encrypt them, then later decrypt them back into the whole file.
To me all this seems to be simple but I am at a loss when Googling this info as it all seems to derive their solutions with so many different providers and methods, and I just don't fully understand whats going on.
So the bottom like is : How can I create a Public/Private Key pair that is AES256 compliant (If that's even right) but I need a 256 bit PKI , then store them in a file to be used in the encrypt decrypt system. Can this be done without using a pass-phrase?
Again I have gotten to the point of encrypting with the use of some examples..
Here is my Generate keys function which works but im not sure if it is creating keys that I need (256)
<pre lang="vb">
Private Shared Sub Keys(publicKeyFileName As String, privateKeyFileName As String)
Dim cspParams As CspParameters = Nothing
Dim rsaProvider As RSACryptoServiceProvider = Nothing
Dim publicKeyFile As StreamWriter = Nothing
Dim privateKeyFile As StreamWriter = Nothing
Dim publicKey As String = ""
Dim privateKey As String = ""
Try
cspParams = New CspParameters()
cspParams.ProviderType = 1
cspParams.Flags = CspProviderFlags.UseArchivableKey
cspParams.KeyNumber = CInt(KeyNumber.Exchange)
rsaProvider = New RSACryptoServiceProvider(cspParams)
publicKey = rsaProvider.ToXmlString(False)
publicKeyFile = File.CreateText(publicKeyFileName)
publicKeyFile.Write(publicKey)
privateKey = rsaProvider.ToXmlString(True)
privateKeyFile = File.CreateText(privateKeyFileName)
privateKeyFile.Write(privateKey)
Catch ex As Exception
Console.WriteLine("Exception generating a new key pair! More info:")
Console.WriteLine(ex.Message)
Finally
' Do some clean up if needed
If publicKeyFile IsNot Nothing Then
publicKeyFile.Close()
End If
If privateKeyFile IsNot Nothing Then
privateKeyFile.Close()
End If
End Try
</pre>
Here is the encryption routine, again i have no idea how to have it use MY key and no password:
<pre lang="vb">
Dim rk As Byte() = Nothing
Dim riv As Byte() = Nothing
Dim salt As Byte() = System.Text.Encoding.ASCII.GetBytes("System.Text.Encoding.ASCII.GetBytes")
Dim pb As New PasswordDeriveBytes("somepassword", salt)
Dim origName As String = TmpStore & "\" & f.ToString
Dim encName As String = origName & ".enc"
cryptoKey = pb.GetBytes(32) : cryptoIV = pb.GetBytes(16)
Try
crm.EncryptData(origName, encName, cryptoKey, cryptoIV)
Dim fi As New FileInfo(origName) : Dim fi2 As New FileInfo(encName)
If (fi.Attributes And FileAttributes.[ReadOnly]) = FileAttributes.[ReadOnly] Then fi.Attributes = fi.Attributes And Not FileAttributes.[ReadOnly]
fi2.CreationTime = fi.CreationTime : fi2.LastWriteTime = fi.LastWriteTime
fi2.Attributes = FileAttributes.[ReadOnly] Or FileAttributes.Archive
File.Delete(origName)
Catch ex As CryptographicException
MessageBox.Show(ex.Message)
Catch ex As IOException
MessageBox.Show(ex.Message)
Catch ex As UnauthorizedAccessException
'i.e. readonly
MessageBox.Show(ex.Message)
End Try
</pre>
Any help is greatly appreciated. Sorry for my lack of understanding, but I am sort of under a deadline and I just cant seem to pull it off with the information out there.
|
|
|
|
|
|
Also this is not a commercial project, this is an internal project I am working on with a few people for our own personal use, mostly experimental.
I've seen that code before, it is very similar to a lot of code out there. My Issue with it is HOW to I use a Public Key of My Choosing to encrypt and Private to decrypt. Also how do I avoid using a password, and it is AES256 compliant?
|
|
|
|
|
Public key cryptography is totally separate from AES
AES is a symmetric algorithm (The person decrypting needs to share a key with the person encrypting)
Symmetric algorithms include things like RC5, AES, 3DES
Public key cryptography refers to asymmetric algorithms. (Stuff encrypted with a public key can be decrypted with a private key and stuff encrypted with the private key can be descrypted with the public key)
Asymmetric/public key algorithms include RSA, ECC.
|
|
|
|
|
Ya, I should have closed this, I got it figured out...
|
|
|
|
|
|
Hi,
I would like to get filenames from a directory and populate its name and icons in a listview.
I tried for the filename and succeded.
Private Sub PopulateData()
Dim FilePath As String = Application.StartupPath & "\users\"
Dim ContentItem As String = Dir(FilePath & "*.dat")
ListView1.Items.Clear()
If ContentItem = "" Then
MsgBox("No users found.")
End If
Do Until ContentItem = ""
ListView1.Items.Add(ContentItem)
ContentItem = Dir()
Loop
End Sub
and I am populating the listview in form loading event.
Private Sub FormCreateUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PopulateData()
End Sub
"users" is a folder from where I want to get the filename details.
But I want to get the file icons also and I don't know how to do this.
Please help.
modified 17-Jul-13 13:41pm.
|
|
|
|
|
Files do not have icons, that is just a mechanism used by Windows Explorer to help provide visual identification of different types of files. You could get the icons out of explorer, or creatre your own, and save them in your program then use the same criteria to add them to your listview. However, since you are only searching for files with the .dat extension there seems little point in having the same icon on each entry.
Use the best guess
|
|
|
|
|