Showing posts with label figure. Show all posts
Showing posts with label figure. Show all posts

Friday, March 30, 2012

Need help building/reading C# SQL Array

I'm stuck and uinder a bit of a time crunch.

I have 5 fields I want to get out of a sql database using a function that I'm writing. I figure it sounds like an array. basically I want to make an array, and fill it up with the results of a sql select, then read the array.

This is what I have so far....

String TempHRAcctCode, TempJobDescription, TempHourlyRate, TempEmplID;
Array TempArray;
TempJobDescription = DDDept.SelectedItem.Text; (to get KeY Value)

SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MYCONN"].ToString());
connection.Open();
SqlCommand command = new SqlCommand("Select HRAcctCode, HourlyRate , EmplID, ... FROM TimeMyProfile WHERE JobDescription = " + TempJobDescription + " ", connection);
SqlDataReader TempDataReader = command.ExecuteReader;
while TempDataReader.Read
(
... OK I GIVE UP!

Thanks in advance



why you want read as an array ?? If you really want to read these data later then load into aDataSetrather than reading from Data Reader into an array and then later read again the array...

using (SqlDataAdapter da = new SqlDataAdapter(command))
{
DataSet ds = new DataSet();

// Fill the DataSet using default values for DataTable names, etc
da.Fill(ds);

connection.Close();

// Return the dataset
return ds;
}

And you can read the data set like

foreach (DataRow dr in ds.Tables[0] .Rows)

{

string myVar = dr["HourlyRate"].ToString()

}

|||

Funny thing is, as I was typing th equestion I was asking myself the same thing, WHY use an array!
Excellent suggestion, it works GREAAT!

Thanks

Wednesday, March 28, 2012

Need help 2

Need Help 2
I am currently converting an access DB to MS SQL.
I am currently trying to figure out how to code this
I need the count of all rows in colum TERM that is > 1 when its grouped by the COLUM NAME
Anyone got any Ideas,I do not know the specifics of MS SQL, however a general approach to your problem might be

select column, count(*)
from table
where term > 1
group by student;

Need Help 2

I am currently converting an access DB to MS SQL.
I am currently trying to figure out how to code this
I need the count of all rows in colum TERM that is > 1 when its grouped by the COLUM NAME
Anyone got any Ideas,i'm not sure wheter i get it right.

hope that it was the thing that you ask for.

Select TERM,Count(<table key>) as Cnt from <Table \name>
Wher TERM > 1
Group by TERM.

If I didn't get it right then just forget about it.
:D|||select count(*) from tbl
where term in
(
select term from tbl group by name having count(*) > 1
)

Friday, March 23, 2012

Need expression help

Can someone one tell me the correct expression to take a figure like 24.09876 and make it show 24% I have tried using the following expression

=FormatPercent(Avg(Fieilds!avgPercentDiscL)) and I keep getting 2409.876% I need it to show 24% please help asap. Thanks

How about this:

= Convert.tostring(convert.toint(Fieilds!avgPercentDiscL)) & "%"

|||

Hello,

It does not reconize the toint I am using C# vs.net 2005 sql report

|||

Yes its all VB/VB.NET syntax irrespective of what you are using..

try toint16 or toinr32..

|||

try this

= Round(Avg(Fieilds!avgPercentDiscL)),0).ToString() + "%"

Bye

Vaibhav

|||

=FormatPercent(Fieilds!avgPercentDiscL.Value,0)

The second parameter specifies the number of digits after the decimal, in this case none.

Wednesday, March 21, 2012

Need basic help with deployment

Hello

I feel like an idiot here, but I cannot figure out how to get Reporting Services to work outside of Visual Studio. I have everything installed (using SQL Server 2005 Express), I have a report, it deploys but when I go to view it, I'm asked for a username and password. I found out how to allow annymous login, but when I do that it says I do not have permissions to access the report on the localhost server.

I can view the report through Visual Studio just fine, but not outside of it.

How can I get it to just allow me to view the report without logging in?

Any help would be greatly appreciated.

Thanks
-JimWell it turns out the problem was that my default browser is firefox, and so it would deploy and try to open it that way and it wouldnt work. If I open it in IE its just fine, go figure :-\sql

Wednesday, March 7, 2012

Need a little help on joining two tables

I have a bit of an issue that I can not seem to figure out and was hoping to get some feedback/advice from you all.

First a little background. I have two databases and I am adding a new table too one of them. However I need to join the two databases but by columns and the columns I want to use to join them will use different data types and values.

Example database 1 column 1 will be groups.group.id and database 2 column 1 will be users.group.id. However in database 2 (users) the group_id will contain different data.

Database 1 group.id will contain a single integer and database 2 group.id I want to have it contain multiple integers seperated by a comma.

Example code:
select groups.group.id, groups.group.name
from groups, users
where groups.disabled='1'
and users.user_id = $user_id
and groups.group.id ? users.group.id

The "?" is where I am having trouble. Does anyone know of a way to join two databases by columns using different data types?

Thanks in advance for any input.
Tdo you mean you want

PSEUDO CODE
select groups.group.id, groups.group.name
from groups, users
where groups.disabled='1'
and users.user_id = $user_id
and groups.group.id IN users.group.id|||Originally posted by fattyacid
do you mean you want

PSEUDO CODE
select groups.group.id, groups.group.name
from groups, users
where groups.disabled='1'
and users.user_id = $user_id
and groups.group.id IN users.group.id

I thought about the IN statement but I do not think that will work. The data in the groups.group.id column will be a single integer say the number 3. Where the data in the user.group.id column could be multiple intergers say 1, 3, 5, 10, etc...

does that make sense?

Thanks
T|||Here, read this...I've add it to my favortites

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830&SearchTerms=udf,csv,string|||you can try patindex or charindex

so something like
select groups.group.id, groups.group.name
from groups, users
where groups.disabled='1'
and users.user_id = $user_id
and patindex('%' + groups.group.id + ',%', users.group.id) <> 0

but it seems like the best way is to not have a list of integers in the user database. You can't seperate the list of integers into seperate records?|||Originally posted by fattyacid
you can try patindex or charindex

so something like
select groups.group.id, groups.group.name
from groups, users
where groups.disabled='1'
and users.user_id = $user_id
and patindex('%' + groups.group.id + ',%', users.group.id) <> 0

but it seems like the best way is to not have a list of integers in the user database. You can't seperate the list of integers into seperate records?

Ok thanks Brett and fatty I will see what I can do.

T|||I highly recommend Jeffs udf...