|
|
Hello all,I'm new to using Crystal Reports and VB.NET Programming here. I have try to Google for how it works. Currently I'm able to show my Blank Reports by Clicking a Button2. I have to ask anyone can tell me how to display my data using the Crystal Report? The following are the code I'm currently working with:
'When the following button Click,the Report will showout.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim objRpt As New FrmCrystalRpt
objRpt.strRptName = New CachedCrystalReport1
objRpt.Show()
End Sub
'The below is my ReportViewer WinForm
Public Class FrmCrystalRpt
Public strRptName As Object
Public strRptFilter As String
Private Sub FrmCrystalRpt_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If strRptFilter <> "" Then
crptVW.SelectionFormula = strRptFilter
End If
crptVW.ReportSource = strRptName
crptVW.Show()
End Sub
End Class
Currently my report showing nothing,I'm wondering how could I make this report show my selection of data from the MySQL5.0 database?
I'm using MySQL ODBC3.51 Driver to connect my Database=logistic_sysdb.
I wish the Crystal Report can show my selection of data below:
Dim SQL4 As String
selectmonth = ComboBox2.SelectedItem
SQL4 = "SELECT * FROM lorry_commission WHERE Lorry_No='" & ComboBox1.SelectedItem & "' AND MONTH(Date)='" & selectmonth & "';"
Try
ObjMyConn.Open()
ObjAdapter = New MySqlDataAdapter(SQL, ObjMyConn)
ObjAdapter.Fill(ds, "Salary44")
Catch ex As Exception
MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly)
Finally
ObjMyConn.Close()
End Try
I guess some parameter is needed to be passed into the Crystal Report as well. How to do that?
Anyone can give me a sample is better so I can learn easier to solve this.
Thanks for reading.
Drex
|
|
|
|
|
You would need to assign a DataSource to the report. Take a look at this article [^]
|
|
|
|
|
I'm still wondering how to use that Crystal Report? Anyone can let me know how to show a dataset table result using a Crystal Report after clicking a button? And how can I pass 3 string parameter to the Crystal report?
Thanks for reading.
Drex
|
|
|
|
|
Hi
I need help regarding the cell formatting event for the datagridview control in windows forms. I looked on the web and I cannot seem to find a perfect solution for this.
I am using VS 2008 and code in VB.NET.
I have a datagridview with many fields amongst which I have an Effective from date.
If the effective from date is smaller than today’s date certain fields should be disabled and made a funny color.
Private Sub DGV1_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DGV1.CellFormatting
Try
If e.RowIndex >= -1 And e.RowIndex <= DGV1.RowCount Then 'Basic index validation
If Not ((DGV1 Is Nothing) OrElse (DGV1.Rows(e.RowIndex) Is Nothing) OrElse (DGV1.Rows(e.RowIndex).DataBoundItem Is Nothing)) Then
Dim dgvRowState As DataRowState = DirectCast(DGV1.Rows(e.RowIndex).DataBoundItem, DataRowView).Row.RowState
'The idea here is to check that it is only for Non Added/Detatched rows where the Effective From Date is smaller than today
If Not (dgvRowState = DataRowState.Added OrElse dgvRowState = DataRowState.Detached) _
AndAlso e.ColumnIndex = EffectFromDataGridViewTextBoxColumn.Index AndAlso CDate(e.Value).Date < Date.Now.Date Then
e.CellStyle.BackColor = My.Settings.ReadOnlyColor
DGV1.Rows(e.RowIndex).Cells(e.ColumnIndex).ReadOnly = True
DGV1.Rows(e.RowIndex).Cells(Field1.Index).ReadOnly = True
DGV1.Rows(e.RowIndex).Cells(Field2.Index).ReadOnly = True
DGV1.Rows(e.RowIndex).Cells(Field1.Index).Style.BackColor = My.Settings.ReadOnlyColor
DGV1.Rows(e.RowIndex).Cells(Field2.Index).Style.BackColor = My.Settings.ReadOnlyColor
DGV1.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.BackColor = My.Settings.ReadOnlyColor
End If
End If
End If
Catch ex As IndexOutOfRangeException
Exit Sub 'Exception added to aviod the following behaviour... When the user adds a new line enters a value and use the mouse to
' navigate to another line, the current new row will be cleared and the cellEndEdit event will be fired. inwhich case the DGV contains
' a blank row that is not dirty. The row "DGV1.Rows(RowIndex).DataBoundItem" part gives an exception for this row
End Try
This works well…
But the problem I am having is when I go to a row where the Effective from date is greater than today and where cells is not read only and change the effective from date to the past that row also changes.
I don’t want this to happen until the user presses on the save button. I debugged the code and found that the dgvRowState variable = UNCHANGHED . Thus it never reaches ADDED or DETATCHED .
Is the way I determine the rowstate wrong? Or is there another way to do this?
Thanks,
Chris
|
|
|
|
|
How to check whether a particuar file exists on FTP server through VB.Net?
|
|
|
|
|
Did you even bother to look at the other answers given when you asked this SAME question just a few posts down? You're off to a bad start.
|
|
|
|
|
--> i want to use SQL SERVER 2000 on windows vista... but it gives me a login error... remember that the sql server is on local system.... i am providing the following connection string from vb.net 2005.....
"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=CSM;Data Source=."
--> but when i use this on windows XP... it works smoothly....
--> plz solve my problem.... thanx....
J A Nasir K
|
|
|
|
|
Is your SQL Server setup to use Windows Authentication?? Have you setup your account in the SQL Server??
This question really has nothign to do with VB.NET and should be in the General Database forum.
|
|
|
|
|
--> are you connecting to an instance? try connecting to:
"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=CSM;Data Source=.\SQLEXPRESS"
--> did you check the settings? (like, allow remote connections and stuff?)
--> it don't make a dif'rence whether it's XP or Vista.
I are troll
|
|
|
|
|
You may also want to read some articles on using SQL Server 2000 on Vista. Google results[^] Using 2000 on Vista is not without it's problems...
|
|
|
|
|
I have .CSV file on my machine. That file doesn't exist on FTP server.i have to write a code in vb.net which checks if the file doesn't exist on server, then only FTP the file.
I have written a small code that does simple FTP and not checks existance of the file on server.
Dim clsRequest As System.Net.FtpWebRequest = _
DirectCast(System.Net.WebRequest.Create("ftp://127.0.0.1/Book1.csv"), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential("me", "test")
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
clsRequest.KeepAlive = False
clsRequest.UseBinary = True
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes("C:\FTP\Book1.csv")
' upload file...
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream() -- the Code gives error here
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Can you please help me.
|
|
|
|
|
I use this simple code
Try
My.Computer.Network.UploadFile(f.Local, f.FTP.ToLower, .Login, Functions.fEncode(.Paswoord))
Catch ex As Exception
sError = ex.Message
sMessage = ex.Message
End Try
I think its easy to transform
the vars sError and sMessage are there becourse I use them later to show all errors in one message
Jan
|
|
|
|
|
The problem with the code above :
DirectCast(System.Net.WebRequest.Create("ftp://127.0.0.1/Book1.csv"), System.Net.FtpWebRequest)
is that Book1.csv doesn't exist on server. So in code line:
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
when it try to read the stream, it doesn't find the file and gives error "the File does not exist"
|
|
|
|
|
hi,
you can use this: http://www.codeproject.com/KB/IP/FTP_Secure.aspx[^]
it's An FTP secure client library for C# (NOT VB.Net sorry)!
to checks existance of the file on server:
FTPFactory ff = new FTPFactory();
ff.setDebug(true);
ff.setRemoteHost(Settings.Default.SourceFtpHost);
ff.setRemoteUser(Settings.Default.SourceFtpUser);
ff.setRemotePass(Settings.Default.SourceFtpPass);
ff.login();
ff.chdir("in");
string[] fileNames = ff.getFileList(string FileMask));
if (fileNames == null || fileNames.Length == 0)
{
throw new Exception("No File was found");
}
|
|
|
|
|
Hi. I'm busy with a app that needs to print xml rendered by xslt. Currently I am printing with internet explorer in the following manner
Dim internetExplorer As New SHDocVw.InternetExplorerClass()
Dim webBrowser As SHDocVw.IWebBrowser2 = CType(internetExplorer, SHDocVw.IWebBrowser2)
'Make the web browser visible
webBrowser.Visible = False
'Display empty page so we have something to manipulate.
Dim noValue As Object = System.Reflection.Missing.Value
webBrowser.Navigate("file://" + fileName, noValue, noValue, noValue, noValue)
While webBrowser.Busy
Threading.Thread.Sleep(500)
End While
'Get access to the webbrowser's document.
internetExplorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, noValue, noValue)
'CType(internetExplorer.Document, mshtml.IHTMLDocument2).close()
Marshal.ReleaseComObject(internetExplorer)
Marshal.ReleaseComObject(webBrowser)
I need to find a different way to do this as the above code gives a com exception. Or I need a workaround for the above code. If anybody can help I would greatly appreaciate it.
Stephen
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
how to bind checkedlistbox with dataset in vb.net (window application)
Er. Jagwinder Singh
|
|
|
|
|
Typing your exact words into Google revealed a bunch of articles on that very subject.
Google results...[^]
|
|
|
|
|
I'm trying to use a class in place of a property and need help with getting the Reflection correct.
Here is a very simple example of what I'm doing:
Public Class Contact
Dim _contactID As zyp_ContactID
Public Sub New()
End Sub
Public Property ContactID() As Guid
Get
Return _contactID.value
End Get
Set(ByVal value As Guid)
_contactID.value = value
End Set
End Property
Public Class zyp_ContactID
Protected Friend Sub New()
End Sub
Dim _contactID As Guid
Public Property value() As Guid
Get
Return _contactID
End Get
Set(ByVal value As Guid)
_contactID = value
End Set
End Property
End Class
End Class
br mode="hold" />
In my previous work I've always just had public properties and used Refelection to hydrate from the database. This allowed me to have a Services class that handled all the hydration through a DatabaseHelper class. There was only one class for each business object that handled hydrating and only one class for the whole program which interfaced to the database. Switching to a different database or even to XML or Web Services was just a one-class change (at least as far as the application code was concerned).
I've run into some real limitations with Properties and creating subclasses appears to be the solution.
I previously used code from Chris Rock, <a href="http://www.rocksthoughts.com/blog/archive/2008/04/24/creating-a-datarow-to-customer-object-mapper.aspx">http:
So now I need help with the following:
For each property in the class
1. Is the property a class ?
2. If so, does the class have a property of "value" ?
3. If so, can we write to the property "value" ?
4. If so, write to the property "value".
Any hints are greatly appreciated...I'm stuck on this and hate the idea of not being able to use a generic mapper class.
As an alternative, is there a way to pass a reference to a function to a sub so that the sub can call the function referenced. This is a backup option if I can't get the generic mapper class to work.
|
|
|
|
|
Your question's formatting is a bit screwed up, making it hard to read. But, I think you're trying to reflect down into child properties of a child class of a class to set it's properties. If so, why? Wouldn't you just create a instance of the target class, set it's properties, then just assign that object to the parent class property? Or am I missing something??
|
|
|
|
|
You are correct that my question formatting is messed up. Unfortunately, I do not see any way to edit my post.
You are correct in what I'm trying to do.
I can't create an instance of the child class as that is handled by the parent class's constructor. Even if I could I would still need to use reflection to determine the child class to create and to assign a value to its "value" property.
|
|
|
|
|
In the bottom right corn of any message you post, you can click on Edit while viewing it.
In that case, I would imagine that you have to pass the new child class to the same code you're already using to fill in the fields and call methods of the parent class. Though, this depends on your parent class' implementation of hosting the child class, if it's a poperty or just a public field. Kind of like recursion walking a directory tree.
|
|
|
|
|
HI - and Help !
I have a small working app that formats a request to Google Maps, an retireves the data.
I copied the code to access a USGS site - and the string works but the code hangs.
Here is the code
Sub GetElevationData()
'This is based upon GoogleMaps access code
'WebRequestString = "http://ws.geonames.org/gtopo30?lat=" & lineArray(LatPosition) & "&lng=" & lineArray(LonPosition) ' this is the eventual string . . . but I am using the following as a test - I can ctrl click and the link comes up ok with a 2 digit elevation.
Dim test1 As String = "http://ws.geonames.org/gtopo30?lat=33.7669399&lng=-116.4134417"
' documentation is available at http://www.geonames.org"
Dim Request As HttpWebRequest = CType(WebRequest.Create(test1), HttpWebRequest)
'Request.MaximumAutomaticRedirections = 5 Tried these (and lots other options - but no joy)
'Request.AllowAutoRedirect = True
Dim Response As HttpWebResponse = CType(Request.GetResponse(), HttpWebResponse)
'This seems to time out
Dim str As Stream = Response.GetResponseStream()
Dim inBuf(10000) As Byte
Dim bytesToRead As Integer = CInt(inBuf.Length)
Dim bytesRead As Integer = 0
While bytesToRead > 0
Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While
MsgBox("bytesread " & bytesRead) 'says 4
'inBuf now has the elevation
'bytesRead has the string length
Dim elevationvalue As String = inBuf.ToString
MsgBox(elevationvalue) ' says system byte []
'lineArray(elevationPosition) = elevationvalue
Response.GetResponseStream().Dispose()
End Sub
Thanks
Bob
|
|
|
|
|
Just a couple of questions off the top of my head... Hangs where?? Which line?? Does it hang for a time, then resume?? Does it hang indefinately?? What's the size of the file it's trying to retrieve?? Is there network activity during the hang??
|
|
|
|
|
HI - and thanks for the reply If you want to chat about this - call me at 510 889 1453
I Posted this reply a bit early - and have found a small glitch
I have modified the code a bit - here is the most recent version using a directcast . . . The other version hung on the response statement - forever - and the network is basically empty during the hang
The reply is a 1-4 byte string. ---> Glitch - the directcast returns the entire web page string -
I found the following as an alternate suggestion - it works - but seems to time out on each request (my test file has 2 records, and the total time is about 12 seconds) - but if I un-comment the test1 string I get sub second response to a browser window.
My DevEnv is VisualStudio2008
WebRequestString = "http://ws.geonames.org/gtopo30?lat=" & lineArray(LatPosition) & "&lng=" & lineArray(LonPosition)
'Dim test1 As String = "http://www.geonames.org/gtopo30?lat=33.7669399&lng=-116.4134417"
Dim Request As HttpWebRequest
Dim Response As HttpWebResponse
Dim reader As StreamReader
Dim sbSource As StringBuilder
Try
Request = DirectCast(WebRequest.Create(WebRequestString), HttpWebRequest)
Request.KeepAlive = False
response = DirectCast(Request.GetResponse(), HttpWebResponse)
If Request.HaveResponse = True AndAlso Not (response Is Nothing) Then
' Get the response stream
reader = New StreamReader(response.GetResponseStream())
' Read it into a StringBuilder
sbSource = New StringBuilder(reader.ReadToEnd())
End If
Catch wex As WebException
' This exception will be raised if the server didn't return 200 - OK
' Try to retrieve more information about the network error
If Not wex.Response Is Nothing Then
Dim errorResponse As HttpWebResponse = Nothing
Try
errorResponse = DirectCast(wex.Response, HttpWebResponse)
MsgBox("The server returned '{0}' with the status code {1} ({2 })." & errorResponse.StatusDescription & " , " & errorResponse.StatusCode & " , " & errorResponse.StatusCode)
Finally
If Not errorResponse Is Nothing Then errorResponse.Close()
End Try
End If
Finally
If Not Response Is Nothing Then Response.Close()
End Try
elevationvalue = sbSource.ToString
modified on Wednesday, February 25, 2009 10:31 AM
|
|
|
|