Click here to Skip to main content
15,919,028 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Automatically installation of .net framework Pin
nishkarsh_k3-Jan-08 22:04
nishkarsh_k3-Jan-08 22:04 
GeneralBackup & Restore Database Pin
vaani3-Jan-08 18:51
vaani3-Jan-08 18:51 
GeneralRe: Backup & Restore Database Pin
John_Adams4-Jan-08 1:52
John_Adams4-Jan-08 1:52 
QuestionProduce reports. Any help plz? Pin
tellytub3-Jan-08 16:57
tellytub3-Jan-08 16:57 
GeneralRe: Produce reports Pin
Christian Graus3-Jan-08 17:17
protectorChristian Graus3-Jan-08 17:17 
GeneralRe: Produce reports Pin
tellytub3-Jan-08 21:23
tellytub3-Jan-08 21:23 
GeneralRe: Produce reports Pin
Christian Graus3-Jan-08 23:47
protectorChristian Graus3-Jan-08 23:47 
GeneralRe: Produce reports. Any help plz? Pin
Tom Deketelaere4-Jan-08 5:25
professionalTom Deketelaere4-Jan-08 5:25 
I'm assuming you use the crystal reports version that is embedded in visual studio 2005

since you already are able to display the records on a form I'm also asuming you can find the sql query needed for this

if both asumtions are correct this might be a way to do what you want:
you create a new report (add --> crystal report)
in the database expert of that report (tab data) you can select you'r database then you get the option to add a table or a command
choose command
now you can enter an sql query wich will be used to create the report
do some layout on the report as you see fit

then on you'r form do the following:

<br />
sub btnprint.click<br />
        Dim rpt As New ProjectVoorblad()<br />
        rpt = reconnectreport(rpt)<br />
        Dim dt As New DataTable()<br />
        dt = FILLDTWITHYOURSQLQUERY<br />
        rpt.SetDataSource(dt) 'this will only work if there is only 1 command and 0 tables in the report <br />
        crvMain.ReportSource = rpt 'crvmain = crystal reports vieuwer<br />
end sub<br />
<br />
Private Function reconnectreport(ByVal report As ReportDocument) As ReportDocument<br />
        Dim connection As IConnectionInfo<br />
        Dim oldServerName As String = report.DataSourceConnections(0).ServerName<br />
        Dim newServerName As String = sservername<br />
        Dim oldDatabaseName As String = report.DataSourceConnections(0).DatabaseName<br />
        Dim newDatabaseName As String = sdbname<br />
        Dim userID As String = susername<br />
        Dim password As String = spass<br />
        report = report<br />
        ' Change the server name and database in main reports<br />
        For Each connection In report.DataSourceConnections<br />
            If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
                And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
                ' SetConnection can also be used to set new logon and new database table<br />
                report.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
                newServerName, newDatabaseName, userID, password)<br />
            End If<br />
        Next<br />
        ' Change the server name and database in subreports<br />
        Dim subreport As ReportDocument<br />
        For Each subreport In report.Subreports<br />
            For Each connection In subreport.DataSourceConnections<br />
                If (String.Compare(connection.ServerName, oldServerName, True) = 0 _<br />
                    And String.Compare(connection.DatabaseName, oldDatabaseName, True) = 0) Then<br />
                    ' SetConnection can also be used to set new logon and new database table<br />
                    subreport.DataSourceConnections(oldServerName, oldDatabaseName).SetConnection( _<br />
                    newServerName, newDatabaseName, userID, password)<br />
                End If<br />
            Next<br />
        Next<br />
        Return report<br />
    End Function<br />


the reconnectfunction reconnects you'r report to the correct database (if it changed)
if the connection to you'r database never changes you don't really need to do this

hope this helps
if you need more explenation let me know

If my help was helpfull let me know, if not let me know why.

The only way we learn is by making mistakes.

GeneralRe: Produce reports. Any help plz? Pin
tellytub4-Jan-08 23:13
tellytub4-Jan-08 23:13 
GeneralRe: Produce reports. Any help plz? Pin
Tom Deketelaere7-Jan-08 1:04
professionalTom Deketelaere7-Jan-08 1:04 
QuestionDisplay String With Quotes Pin
Dan Suthar3-Jan-08 15:05
professionalDan Suthar3-Jan-08 15:05 
GeneralRe: Display String With Quotes Pin
Christian Graus3-Jan-08 15:15
protectorChristian Graus3-Jan-08 15:15 
AnswerRe: Display String With Quotes Pin
Nilesh Hapse3-Jan-08 18:32
Nilesh Hapse3-Jan-08 18:32 
AnswerRe: Display String With Quotes Pin
Dan Suthar3-Jan-08 23:36
professionalDan Suthar3-Jan-08 23:36 
GeneralFill By Methods Vs. Binding Source Pin
AAGTHosting3-Jan-08 12:43
AAGTHosting3-Jan-08 12:43 
GeneralRe: Fill By Methods Vs. Binding Source Pin
Dave Kreskowiak3-Jan-08 14:24
mveDave Kreskowiak3-Jan-08 14:24 
Generala coding problem Pin
s3rro3-Jan-08 10:42
s3rro3-Jan-08 10:42 
GeneralRe: a coding problem Pin
Dave Kreskowiak3-Jan-08 10:58
mveDave Kreskowiak3-Jan-08 10:58 
GeneralRe: a coding problem Pin
Ray Cassick3-Jan-08 11:30
Ray Cassick3-Jan-08 11:30 
QuestionApplication exits without error message Pin
Volker Weichert3-Jan-08 9:06
Volker Weichert3-Jan-08 9:06 
GeneralRe: Application exits without error message Pin
Christian Graus3-Jan-08 11:12
protectorChristian Graus3-Jan-08 11:12 
GeneralRe: Application exits without error message Pin
Volker Weichert4-Jan-08 1:55
Volker Weichert4-Jan-08 1:55 
GeneralCannot cast from ControlCollection to ControlCollection Pin
Ed Hill _5_3-Jan-08 6:30
Ed Hill _5_3-Jan-08 6:30 
GeneralRe: Cannot cast from ControlCollection to ControlCollection Pin
Ed Hill _5_3-Jan-08 6:34
Ed Hill _5_3-Jan-08 6:34 
GeneralRe: Cannot cast from ControlCollection to ControlCollection Pin
Dave Kreskowiak3-Jan-08 7:16
mveDave Kreskowiak3-Jan-08 7:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.