|
Hello,
Thanks for all your responses. I have gone with typed dataset. However, I have a problem displaying the data in the report. I have created an typed dataset.xsd called DS_JobSheet.xsd. I have previewed the data and it displays everything. I have created the reports.
In the report I have select database expert | project Data | ADO.Net Dataset. I have select my dataset and selected the table.
I have dragged the fields on to the report. I think everything seems to be ok here.
The code for filling the report is below. I have added a grid to the report to see if that gets filled and it does. I just don't understand why my report does not show any data.
I have imported
CrystalDecisions.CrystalReports.Engine
CrystalDecisions.Shared
Can any correct if I have done something wrong.
Many thanks,
Steve
<br />
Private Sub frmJobSheet1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Dim customerReport As New rptJobSheet1()<br />
Dim DS_JobSheet As DataSet 'DS_JobSheet is the .xsd data schema, data has been generated <br />
Dim IDNumber As Integer<br />
Dim cnn As New SqlConnection()<br />
Dim da As New SqlDataAdapter()<br />
Dim cmd As New SqlCommand()<br />
<br />
cnn.ConnectionString = "server=steve02\ssd02; database=serviceMaster; pwd=a123; user id=sa"<br />
<br />
cmd.CommandType = CommandType.Text<br />
cmd.CommandText = "SELECT * FROM Incident"<br />
DS_JobSheet = New DataSet<br />
<br />
Try<br />
cnn.Open()<br />
cmd.Connection = cnn<br />
<br />
da.SelectCommand = cmd<br />
da.Fill(DS_JobSheet)<br />
<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
<br />
IDNumber = 68 'Display record for ID number 68 this number exists in the database table<br />
<br />
customerReport.SetDataSource(DS_JobSheet)<br />
<br />
<br />
Me.CrystalReportViewer1.Refresh()<br />
Me.CrystalReportViewer1.SelectionFormula = "{Incident.IncidentID} = " & IDNumber & " "<br />
Me.CrystalReportViewer1.ReportSource = customerReport 'Application.StartupPath & "\JobSheetReport\rptJobSheet1.rpt"<br />
<br />
<br />
Me.UltraGrid1.DataSource = DS_JobSheet.Tables(0).DefaultView 'Data is displayed in the datagrid so this is ok<br />
Me.UltraGrid1.Refresh()<br />
<br />
Me.CrystalReportViewer1.Show()<br />
<br />
End Sub<br />
-- modified at 12:38 Thursday 26th October, 2006
|
|
|
|
|
Hi Steve,
I don't see anything wrong but you obviously have a problem if no data is showing up. If anywhere, think your problem lies in the report selection formula statement -
Me.CrystalReportViewer1.SelectionFormula = "{Incident.IncidentID} = " & IDNumber & " "
Have you tried filling the dataset and viewing all the data without filtering it by the variable IDNumber? Does data show up then?
Is it possible to take an alternative approach to viewing the data? If I'm reading your code correctly, I see that you're filling the dataset with all the records from the database and then displaying only one record from there using the IDNumber variable. Loading and displaying the report would be much faster if you filled the dataset only with the record that you need.
|
|
|
|
|
Hello,
Thanks for your response.
Still can't get it working. I have done the following.
customerReport.Database.Tables(0).SetDataSource(DS_JobSheet2)'doesn't work
and removed the following
'Me.CrystalReportViewer1.SelectionFormula = "{Incident.IncidentID} = " & IDNumber & " "
Datagrid is being populated, as it fills the grid.
I think it must have something to do from filling the dataset and passing that to the CR.
My friend tried a simpliar example, and he had the same problem.
What can it be?
Any help would be so grateful,
Steve
|
|
|
|
|
Hi Steve, check your mail
|
|
|
|
|
<br />
Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer<br />
Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument<br />
CrystalReportViewer1.ActiveViewIndex = 0<br />
CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle<br />
CrystalReportViewer1.DisplayGroupTree = False<br />
CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill<br />
CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)<br />
CrystalReportViewer1.Name = "CrystalReportViewer1"<br />
<br />
Dim QueryString As String = "select * from TableName" 'Your Query here<br />
Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here<br />
Connection.Open()<br />
<br />
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(querystring, connection)'Passing the query in the connection<br />
Dim DataSet As DataSet = New DataSet() 'DataSet<br />
Adapter.Fill(DataSet)<br />
Dim DataTable As DataTable = New DataTable 'DataTable<br />
DataTable = DataSet.Tables(0) 'filling the datatable here<br />
Report.Load(Application.StartupPath & "/ReportName.rpt") 'Report Name Here<br />
Report.SetDataSource(DataTable)<br />
CrystalReportViewer1.ReportSource = Report<br />
|
|
|
|
|
Hi,
I need to access a database on a remote computer using ado.net. I'm using Ms Sql server 2000, and my computer is not on the same domain as the remote computer, but I physically have access to this computer. Can somebody help me about the procedure to use ? I already accessed ms sql 2000 databases but it was on my computer, so the server was '(local)'. How do I do for a distant one ? Is there a way of using the remote computer IP adressm, or something else ?
Thanks for helping.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
alter your current connection string to point to the remote SQL Server IE:
User id=YOURUSERNAME; password=YOURUSERsPASSWORD; Data Source=YOURREMOTESQLSERVER; Initial Catalog=YOURDATABASENAME;
Hope this is helpful.
|
|
|
|
|
User id=username; password=userpassword; Data Source=120.120.120.120; Initial Catalog=dbName;
Data Source=IP Address where your database is located.
i thing it is use full for you...!
Pavan Pareta
|
|
|
|
|
this statement wont work
imports microsoft.office.core.commandbar
which dll should i import??
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Office.dll
---
b { font-weight: normal; }
|
|
|
|
|
i'm not getting microsoft.office.core.commandbar class in office.dll
i've got .commandbarclass there but .commandbar is not there.
again adding ref. to office causes me ambiguty with Microsoft.Office.Core in commanbar etc objects.
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
|
hi guys
iam new to windows forms, iam a web developer.
Can i ask for a function that copies employees from one list box to another when pressing on a button.
where display memeber is empName and value =id
any help?
thanks
|
|
|
|
|
Are you wanting to move the entire list of names to the listbox or only selected names?
|
|
|
|
|
Actually i want to do both. I want to move only selected items first then to have an option like a check box or so to be able to move all. Thanks in advance.
|
|
|
|
|
Hi everybody !
I'm programming control interfaces using a PocketPC running under Windows Mobile 5, and I use VB.NET.
I'm trying for a while to create my own control component (actually it's should be a speedometer), but I'd like to NOT refresh all the control when I change the value it should displays
I explain myself :
I've got what I call a background : a line, an ellipse, a filled ellipse and a fille rectangle
I've got a needle (to display the speed) : an array of points connected by a polygon and a filled polygon
What I'd like to do is to refresh only the needle, not the background (because it blink because of the powerlessness and the speedlessness of the PocketPC)
I found on this site that I have to override the "OnCreateControl " sub, but it does'nt exist ! (so I can't override it)
Thank you for your help
Regards,
Ch'Portos.
Yop Yop !!
|
|
|
|
|
You should have asked this in the Mobile Development[^] forum. The .NET Compact framework doesn't support everything it's desktop cousin does.
I don't do mobile dev so I have no idea if this is supported. But, in the desktop world, you set up your ConstrolStyles, turning on DoubleBuffering and handling all the painting yourself:
Public Class MyControl
Public Sub New
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
SetStyle(ControlStyles.UserPaint, True)
End Sub
Then you override OnPaint where you do all of your painting. This should eliminate the flicker.
Another method would be to just paint your entire control to an offsreen Bitmap, then just copy the bitmap to the drawing surface in your OnPaint:
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim backBuffer As New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height)
Dim bg As Graphics = Graphics.FromImage(backBuffer)
' Do all your control painting here
bg.draw...this and that
bg.Dispose()
' Now draw your buffered image to your control surface
Dim g As Graphics = e.Graphics
g.DrawImage(backBuffer, 0, 0, backBuffer.Width, backBuffer.Height)
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks to the help from yesterday i have managed to get thus far, just one stumbling block left if any one can help
Code from login
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
Dim mydataSet As New DataSet
Using connection As New SqlConnection("Data Source=TESTSQL;Initial Catalog=DevDataBase;Integrated Security=True")
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = New SqlCommand("Select Count(*) from DevDataBase.dbo.Operators where Name = '" & logon1.UserName & "' and Psw = '" & logon1.Password & "'", connection)
adapter.Fill(mydataSet)
MsgBox(mydataSet.Tables(0).Rows(0)(0))
End Using
End Sub
If the user name and password are correct then I get a count of 1. How would this work with a stored procedure
Stored Procedure Name is 'OpersLogon' and the parameters supplied are
@OperatorName varchar(20),
@OperatorPassword varchar(20),
@ReturnValue Int Output
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Dim sqlConn As SqlClient.SqlConnection<br />
Dim command As SqlClient.SqlCommand<br />
Dim adapter As SqlClient.SqlDataAdapter<br />
Dim table As DataTable<br />
<br />
Try<br />
sqlConn = New SqlClient.SqlConnection("YOUR CONNECTION STRING")<br />
command = New SqlClient.SqlCommand("OpersLogon", sqlConn)<br />
With command<br />
.Parameters.AddWithValue("@OperatorName", Server.HtmlEncode(logon1.UserName))<br />
.Parameters.AddWithValue("@OperatorPassword", Server.HtmlEncode(logon1.Password))<br />
.CommandType = CommandType.StoredProcedure<br />
End With<br />
adapter = New SqlClient.SqlDataAdapter(command)<br />
table = New DataTable<br />
adapter.Fill(table)<br />
If CInt(table.Rows(0)(0)) <> 1 Then Throw New ApplicationException("Invalid User Credentials.")<br />
Catch ex As Exception<br />
' Report or document the exception<br />
Finally<br />
If sqlConn.State <> ConnectionState.Closed Then sqlConn.Close()<br />
End Try
Might not be the most efficaint code but I've been using it on a site for the past year and a-half with no troubles.
|
|
|
|
|
That will work a treat,
Its very similar to what i use in a standered VB6 application, just didnt think it would work on this for some reason. Thats the great thing about this site, theres always something more to learn
Thanks again
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
AreJay,
seems like ive hit a small problem, what happens if the stored proc returns a integer , ie in the stored procedure its returning an int as an output parameter;
in the stopred proc @ReturnValue INT OUTPUT
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Pete Newman wrote: @ReturnValue INT OUTPUT
table = New DataTable<br />
adapter.Fill(table)<br />
If CInt(table.Rows(0)(0)) <> 1 Then
The output is being returned into the datatable then tested with table.Rows(0)(0). I understand that the stored proc may have a param of @ReturnValue INT OUTPUT, is this stopping the proc from running because your not assigning an output variable? I don't use an output param with my stored procs, I'll need to test the code I've posted and get back to you.
|
|
|
|
|
cheers AreJay
i know there has to be a way... but well its beyond me
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Hi,
I have some problems with:
Dim oType As System.Type = oDAOModel.GetType
Dim oPropertyInfo As Reflection.PropertyInfo = oType.GetProperty("connected")
Dim oObjectAux As Object = oPropertyInfo.GetValue(oDAOModel, Nothing)
When the propety connected (Boolean type) is nothing, "If oObjectAux is Nothing Then" says that oObjectAux not is nothing, but "If CType(oObjectAux, Boolean) is Nothing Then" works fine.
How I can check if properties are Nothing dinamically (without knowing property type)?
Thanks,
Mario
|
|
|
|
|
I can't understand what you're trying to do with this...
But, if your cast an Object to a value type, is will never be Nothing. I don't get what you're trying to do with this???
amapumu wrote: How I can check if properties are Nothing dinamically (without knowing property type)?
You can't. Value types are never Nothing.
What is this code supposed to be doing? Why are you doing it this way?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|