Showing posts with label display. Show all posts
Showing posts with label display. Show all posts

Wednesday, March 21, 2012

How to loop through this sql table and display in ms access listbox

I have a table in SQL, that I know how to connect to using ADO, but I
need help on how to read records from that table.

So on a form I have a listbox where I want to populate that and i have
a textbox with a userid.

Here is an example of the table:
USER ID TYPE PAYMENT
=====================
0001 CARD 150.00
0001 CASH 250.00
0002 CASH 175.00

If I have 0001 in the txtuserid textbox, I then want to display in
the listbox:
CARD 150.00
CASH 250.00

How would I do this?

thanksRon (pts4560@.yahoo.com) writes:

Quote:

Originally Posted by

I have a table in SQL, that I know how to connect to using ADO, but I
need help on how to read records from that table.
>
So on a form I have a listbox where I want to populate that and i have
a textbox with a userid.
>
>
Here is an example of the table:
USER ID TYPE PAYMENT
>=====================
0001 CARD 150.00
0001 CASH 250.00
0002 CASH 175.00
>
>
If I have 0001 in the txtuserid textbox, I then want to display in
the listbox:
CARD 150.00
CASH 250.00
>
How would I do this?


Set cmd = CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cnn
cmd.CommandType = adCmdText
cmd.CommandText = "SELECT TYPE, PAYMENT FROM tbl WHERE USER_ID = ?"
cmd.Parameters.Append CreateParameter("@.userid", adInteger. _
adParamInput, , txtuserid.text)
rs = cmd.Execute

--
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

Friday, March 9, 2012

How to Limit the number of rows returned with MSSQL, like the MySQL Limit clause.

hi

I use to work with mysql but now I need mssql. Can somebody tell my how I canwork around LIMIT to select a number of records so I can display 10 records at a time in stead of all?

ThanksI think there is nothing exactly the same as LIMIT. But you can use TOP to get limited records. e.g. TOP 10 will return 10 records but this can not be used like TOP 20,10.

Moreover, you can loop the results to reach to your required result number and start displaying them. But this is not a good approach

I don't know the current implementation of TOP. I read this somewhere.|||I've edited the title of the thread, and moved it to the Sql Server / MSSQL Forums.

Moderator

how to limit number of rows showing each page?

Hi All,

i couldn't find how to set up the number of rows displaying on each page?

i wanna each page display 20 rows.

Thanks

Nick

There's no explicit way of doing it, but it can be achieved by placing your table inside a list control then add a grouping with the folowing expression:

= Ceiling(RowNumber(Nothing)/20)

Make sure you check the page break at end option.

|||

Cool..

I got it.. thank you very much,, Adam

Wednesday, March 7, 2012

How to launch package from client machine, display progress and finally results?

Please help. I'm completely new to SSIS, and I was hoping someone could point me in the right direction(s).

I am developing a winforms client app, and I need to be able to provide the user with the ability to import data in CSV format into our application's database.

I'd like to use SSIS if possible, as long as what I am trying to do isn't near impossible.

I'm thinking of a UI where the user can specify a flat file (CSV) to upload and be processed by an SSIS package on a remote database server.

This package will be responsible for validating the CSV file and inserting data into the database as appropriate.

Is there a way I can:

    launch an SSIS package remotely, from a winforms app on the client machine that is not running SQL server (preferably asynchronously) -- and pass it some parameters, including the import file itself

    (optionally) provide progress feedback to the client pc to let them know it is being processed

    display a nice SSRS report on the client upon completion that tells them exactly what the success/failure of the import was (how many rows processed, which ones failed and why, etc)

Any helpful examples, links, etc would be most appreciated.

Thanks in advance!

1 - How about hosting it on the SQL Server, and start ith through T-SQL. The best way to get the asycn behaviour is to use a job.

How to: Run a Package Using a SQL Server Agent Job
(http://msdn2.microsoft.com/en-us/library/69d3958c-6abc-41ae-8428-312917867c9a.aspx)

2 - You will not get anything back from the job, as it you have no handle back to it. You could turn on logging in your package, perhaps to SQL Server, and then query the table on a polling basis to provide progress to a user.

3 - A combination of SQL logging and some custom logging within the package and you should be able to achieve this.