Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Wednesday, March 21, 2012

Open SQL 2005 database question

Shoud a SQL 2005 database remain open in a Visual Basic program, or should
it be opened and closed in every subroutine?

Thanks for any info.Charlie wrote:

Quote:

Originally Posted by

Shoud a SQL 2005 database remain open in a Visual Basic program, or should
it be opened and closed in every subroutine?


How often will the VB program access the database?|||Charlie (jadkins4@.yahoo.com) writes:

Quote:

Originally Posted by

Shoud a SQL 2005 database remain open in a Visual Basic program, or should
it be opened and closed in every subroutine?


You don't really open or close the database, but you connect and disconnect
from the server.

It's common to do as you say open and disconnect. It's not really cheap to
open a connection to SQL Server. However, the client API maintains a
connection pool, so behind the scenes the connection is open, and is reused
when you connect anew. (If there is no connection for a certain amount of
time, typically 60 seconds, the connection is closed for real.)

Then again, in a two-tier application it's not really any major flaw to
have a global connection that you keep open.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Very frequently.

"Ed Murphy" <emurphy42@.socal.rr.comwrote in message
news:4726a8c5$0$11450$4c368faf@.roadrunner.com...

Quote:

Originally Posted by

Charlie wrote:
>

Quote:

Originally Posted by

>Shoud a SQL 2005 database remain open in a Visual Basic program, or
>should it be opened and closed in every subroutine?


>
How often will the VB program access the database?

Tuesday, March 20, 2012

Open printer dialog in runtime mode in VB6

Hay,
when i open report from visual basic 6 using viewer its give me only printer icon which only print direct to deafult printer without any option to choose another printer.
How i can choose which printer i want in runtime in VB6If found this:

Report.PrinterSetup 0
Report.PrintOut

But for me it was easier to create my own Printer Selection form. I added a combobox for the Printer (filling it by looping through the Printers Collection), option buttons for All Pages or a specific page range, and a spinner for number of copies. I also added properties to the SelectPrinter Form to hold the data. Once the user picks the options and clicks 'Print', VB send the data to Crystal's .Printout.

Private Sub CRViewer_PrintButtonClicked(useDefault As Boolean)

Dim cOrientation As CRPaperOrientation
Dim cSize As CRPaperSize

useDefault = False

'Capture the original Orientation and Paper Size,
' SelectPrinter resets Landscape to Portrait
cOrientation = Report.PaperOrientation
cSize = Report.PaperSize

'Reset Form and all data by calling the NewData function on the SelectPrinter Form
frmSelectPrinter.NewData

'Set Max Number of Pages
frmSelectPrinter.MaxPages = Report.PrintingStatus.NumberOfPages

'Show Form and wait for User
frmSelectPrinter.Show vbModal

If Len(frmSelectPrinter.DeviceName) > 0 Then
'If a device is selected, print report
Report.SelectPrinter frmSelectPrinter.DriverName, _
frmSelectPrinter.DeviceName, frmSelectPrinter.Port

'Set the Orientation and Paper Size to the original,
' SelectPrinter resets Landscape to Portrait
Report.PaperOrientation = cOrientation
Report.PaperSize = cSize

Report.PrintOut False, frmSelectPrinter.Copies, , _
frmSelectPrinter.FromPage, frmSelectPrinter.ToPage


End If

End Sub

Saturday, February 25, 2012

only 1 data row shows up in preview - should have 10

I am relatively new to Reporting services. I have a real basic dataset
select * from tbl1
tbl1 contains 10 rows and 6 fields. I have 6 textboxes in the layout view.
I linked each textbox to a field in the dataset. When I go to preview, I
only see one row of the 10 rows and only 1 page. What do I need to do to
show the rest of the rows (on the same page)? Any suggestions appreciated.
Thanks,
RichWell, I found part of my problem. When I right-click on a textbox I select
"expression" which brings up a dialog box with a variety of selections. I
want to select Fields but see a message that the report has not been linked
to a dataset. So I go to the Dataset option and select fields from there.
But each of those fields has the "First" function leading the expression.
So now my question is: how do you link a dataset to the report?
"Rich" wrote:
> I am relatively new to Reporting services. I have a real basic dataset
> select * from tbl1
> tbl1 contains 10 rows and 6 fields. I have 6 textboxes in the layout view.
> I linked each textbox to a field in the dataset. When I go to preview, I
> only see one row of the 10 rows and only 1 page. What do I need to do to
> show the rest of the rows (on the same page)? Any suggestions appreciated.
> Thanks,
> Rich|||I think I figured this out. You have to add a table to the layout from the
Toolbox and that is where select your dataset.
Just posting for posterity
"Rich" wrote:
> Well, I found part of my problem. When I right-click on a textbox I select
> "expression" which brings up a dialog box with a variety of selections. I
> want to select Fields but see a message that the report has not been linked
> to a dataset. So I go to the Dataset option and select fields from there.
> But each of those fields has the "First" function leading the expression.
> So now my question is: how do you link a dataset to the report?
>
> "Rich" wrote:
> > I am relatively new to Reporting services. I have a real basic dataset
> >
> > select * from tbl1
> >
> > tbl1 contains 10 rows and 6 fields. I have 6 textboxes in the layout view.
> > I linked each textbox to a field in the dataset. When I go to preview, I
> > only see one row of the 10 rows and only 1 page. What do I need to do to
> > show the rest of the rows (on the same page)? Any suggestions appreciated.
> >
> > Thanks,
> > Rich