Showing posts with label type. Show all posts
Showing posts with label type. Show all posts

Tuesday, March 27, 2012

Access DB via SqlDataSource....need result in DataSet

Hi all...I've set the DataSourceMode = SqlDataSourceMode.DataSet, and did a .Type return and found that it is actually returning a DataView. A component I am trying to avoid rewriting...requires a dataset that loops through the table, does some cool formatting to a datagrid and then rebinds.

Here's the code that I'm trying to send the dataset to...maybe there's just a couple of changes that could make it work with a DataView?

int i = 0;
string prevsub = "";
while (i <= ds.Tables[0].Rows.Count - 1)
{
DataRow dr = ds.Tables[0].Rows[i];
string sub = dr["SubHeading"].ToString();
if (sub != prevsub)
{
prevsub = sub;
DataRow newrow = ds.Tables[0].NewRow();
newrow["Title"] = "SubHeading";
newrow[columnName] = dr[columnName];
ds.Tables[0].Rows.InsertAt(newrow, i);
i++;
}
i++;
}

DataView is very close to the dataset object in this context.

my test code:

DataView dv = (DataView) SqlDataSource1.Select(DataSourceSelectArguments.Empty);


int i = 0;
string prevsub = "";
while (i <= dv.Table.Rows.Count - 1)
{
DataRow dr = dv.Table.Rows[i];
string sub = dr["mycol1"].ToString();
if (sub != prevsub)
{
prevsub = sub;
DataRow newrow = dv.Table.NewRow();
newrow["mycol1"] = "SubHeading";
newrow["mycol2"] = dr["mycol2"];
dv.Table.Rows.InsertAt(newrow, i);
i++;
}
i++;
}

Hope this helps.

|||Hi there. Thanks so much limno! That did the trick. I was hoping that the dv would be similar enough to be able to use this code. Great to know and use for the future. Much appreciated!

Sunday, March 25, 2012

Access chart Palette color set in custom code

Hi, all. I am doing a pie chart, to display the market value for each asset type. I couldn't put the market value and asset type together in the legend, so I create another table behind the pie chart. Since I want to use the table to replace the legend of pie chart, I plan to put a retangle with same color of each asset type in the pie chart. How can I use the Palette color serizes like Excel, Earth Tone, Pastel in the assemble custom code?

I recommend to just define your own color palette and use it in both the chart and the custom table legend. Check this blog article for an example and explanations: http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx

-- Robert

|||Thanks, Robert. It helps

Access chart Palette color set in custom code

Hi, all. I am doing a pie chart, to display the market value for each asset type. I couldn't put the market value and asset type together in the legend, so I create another table behind the pie chart. Since I want to use the table to replace the legend of pie chart, I plan to put a retangle with same color of each asset type in the pie chart. How can I use the Palette color serizes like Excel, Earth Tone, Pastel in the assemble custom code?

I recommend to just define your own color palette and use it in both the chart and the custom table legend. Check this blog article for an example and explanations: http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx

-- Robert

|||Thanks, Robert. It helps

Thursday, March 8, 2012

About Wait Type

SQL Server 2k Enterprise sp3
Windows 2k Server
XeonX2*2 2GMhz2G RAMRAID5
After excuting 'dbcc sqlperf(WAITSTATS)',The WaitType,including
RESOURCE_QUEUELATCH_EXCXPACKETPAGEIOLATCH_SH , often appears .
But CPU's Usage is less than 60% and RAM has 90M free.
http://sqldev.net/misc/waittypes.htm did not tell me how to optimizing SQL
server performance .
I don't know whether I should add the CPU ,or the RAM, or anything else.
I want the SQL Server to do its best.
Thanks
Are you experiencing any kind of problems on your sql server that may need
more memory?
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.

Tuesday, March 6, 2012

About Wait Type

SQL Server 2k Enterprise sp3
Windows 2k Server
XeonX2*2 2GMhz£¬2G RAM£¬RAID5
After excuting 'dbcc sqlperf(WAITSTATS)',The WaitType,including
RESOURCE_QUEUE¡¢LATCH_EX¡¢CXPACKET¡¢PAGEIOLATCH_SH, often appears .
But CPU's Usage is less than 60% and RAM has 90M free.
http://sqldev.net/misc/waittypes.htm did not tell me how to optimizing SQL
server performance .
I don't know whether I should add the CPU ,or the RAM, or anything else.
I want the SQL Server to do its best.
ThanksAre you experiencing any kind of problems on your sql server that may need
more memory?
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.

About Wait Type

SQL Server 2k Enterprise sp3
Windows 2k Server
XeonX2*2 2GMhz2G RAMRAID5
After excuting 'dbcc sqlperf(WAITSTATS)',The WaitType,including
RESOURCE_QUEUELATCH_EXCXPACKETPAGE
IOLATCH_SH, often appears .
But CPU's Usage is less than 60% and RAM has 90M free.
http://sqldev.net/misc/waittypes.htm did not tell me how to optimizing SQL
server performance .
I don't know whether I should add the CPU ,or the RAM, or anything else.
I want the SQL Server to do its best.
ThanksAre you experiencing any kind of problems on your sql server that may need
more memory?
Vikram Jayaram
Microsoft, SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.

about the type field : datetime and smalldatetime

hi all,
the field type :datetime and smalldatetime, i still can't understand.
everytime when i inserted the data to the db, i also get the error message"System.Data.SqlClient.SqlException: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."
i must change the field type tostring, so that i can insert data
my code
txt_datetime.text = '5/2/2006'
insert into datetime (datetime) values ('"& txt_datetime.text & "')"

can anybody tell me the reason?

thank you!!In your SQL statement:

insert into datetime (datetime) values ('"& txt_datetime.text & "')"

Is your table named datetime? Isn't that a keyword? If that's not the problem, then can you post the source code where you are inserting the value?|||

What culture is your SQL Server running under?

I'm guessing this statement will fail as well:

SELECT CAST('5/2/2006' as datetime)

Try running that as a query.

But beyond that... Stop generating SQL Statements by using string concatenation and your problem will go away.

dim conn as new sqlconnection("{Connection string}")
conn.open
dim cmd as new sqlcommand("INSERT INTO [datetime](datetime) values (@.datetime)",conn)
cmd.parameters.add("@.datetime",sqldbtype.datetime).value='5/2/2006'
cmd.executenonquery
conn.close

|||

hi all,

first at all, thank you for reply
now i solved the problem and i think i know the reason, because the sql server and .net software are in difference language , sql server is tradition chinese version and .net software is in english version . the field type - datetime in sql server (english version ) is "dd/mm/yyyy" but in chinese is "mm/dd/yyyy" and when i insert the data to the db via the .net application, the datetime format is"dd/mm/yyyy", so i have to splite the datatime string and change it to "mm/dd/yyyy".

hijcasp,
my table name is called paper and the field name is deadline.
txt_deadline.text = '5/2/2006'
dim deadline_array = splite(txt_deadline.text, "/")
dim deadline as string
deadline = deadline_array.(1) & "/" & deadline_array(0) & "/" & deadline_array(2)
"insert into paper(deadline) values(" & deadline & ")"

hi,Motley
"Stop generating SQL Statements by using string concatenation ", why i should stop to use concatenation??

|||

1) Because you run into problems like the one you mentioned.

2) Because string concatenating sql strings will suffer from SQL Injection attacks if you aren't really careful.

3) Performance.

4) Portability.

5) Maintanability.

6) Readability.

If at a later time you decide to change the SQL Server culture, your code breaks. If you decide to change your .NET culture, your code breaks. If you decide you want to localize your application to multiple cultures, your code breaks. The code I gave you runs no matter what culture your .NET appliction is, or what culture your SQL Server is, and runs faster and demands less resources of the SQL Server making it more scalable.

Just as a point of clarification, the issue wasn't that the language was different, it's that the culture formats of the .NET application and the SQL Server were different. The date format for en-US (English in the United States) is mm/dd/yy. The date format for en-GB (English in Great Britian) is dd/mm/yy. You had the right idea on the cause, just not the correct term. Cultures are made up of a language and a locale. The language part of the culture wasn't the problem, it's the locale part that determines what format dates, times, numbers, currency are in, and that's the part that caused you the problem.

Friday, February 24, 2012

About SQL field Type

Hi Friends
I have question.
I connected oracle and MS access tables(via Delphi7).
I wanna get type of field in indicated table. For example if it is
integer or boolean e.t.c

Please tell me the SQL function or whatever that retrievs type of field.
Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Ulan yrysbaev (ulasir@.yahoo.com) writes:
> Hi Friends
> I have question.
> I connected oracle and MS access tables(via Delphi7).
> I wanna get type of field in indicated table. For example if it is
> integer or boolean e.t.c
> Please tell me the SQL function or whatever that retrievs type of field.

Since you use different platforms, you should be using the
INFORMATION_SCHEMA views, which are part of the ANSI standard. But
I have no idea whether any of Access and Oracle supports them.

You are probably better off asking in comp.databases.ms-access and
comp.databases.oracle.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Thursday, February 16, 2012

About Merge Join Component

Hi, I'm using a Merge Join Component of Inner Join type to retrieve from the right pipeline some records to append to the ones coming from left pipeline according to the join citerias defined on the compnent.

Is there any way to know which are the records coming from the left pipeline that doesn't match the join criterias?

In the following I'll try to do an axample.

LF pipeline:

Column0 Column1 Column2

1 aaaa aa11

2 bbbb bb11

3 cccc cc11

4 dddd dd11

RT pipeline:

ColumnA ColumnB

1 aa22

4 dd22

On exiting from the MergeJoin, defining “Column0” for LT as join key and “ColumnA” for RT and as output data all the columns of the LT pipeline and the only ColumnB from the RT pipeline it should be obtained the following records:

Column0 Column1 Column2 ColumnB

1 aaaa aa11 aa22

4 dddd dd11 dd22

and the records from the LT pipeline:

2 bbbb bb11

3 cccc cc11

shouldn't go in the output from the Merge Join Component.

What I need to know is which are these last lines because I need to manage them.

Thanks!

If you need to get both matches and mismatches; shouldn't you be using an left or full outer join instead? then you could place a conditional split to redirect and manage rows that did not match.

BTW, Have you loked at the Looukup transformation instead?

You could have a lookup based on the 2 set of row (assuming is an OLE DB data source) and then use the error output to redirect the rows that don't match. That way you get 2 outputs; the matches and the mismatches.

|||

Hi,

I read your answer and I think I need more details about it.

When you say:

“….shouldn't you be using an left or full outer join instead?”

I tell you:

If I use a left outer join, on output I have both matches and mismatches records. Can you tell me on what I have to do the conditional split? Can you show me any example to let me understand better?

When you say:

“…BTW, Have you loked at the Looukup transformation instead?”

I tell you:

In the package both the two sets of rows (LT pipeline and RT pipeline) doesn't came from a datasource but they are a result of an intermediate elaboration of data read at the beginning of package.

Thanks again!

|||When you use the LEFT OUTER JOIN, take columnB and test if it is NULL or not. If it is NULL then you are looking at a record that didn't have a match.|||

Thanks,

I'll try to do that!

|||Actually, in thinking about it, the better thing to do is to take COLUMNA and pass it through the merge join transformation. Check that for NULL, not COLUMNB.|||

SabAlo wrote:

Hi,

I read your answer and I think I need more details about it.

When you say:

“….shouldn't you be using an left or full outer join instead?”

I tell you:

If I use a left outer join, on output I have both matches and mismatches records. Can you tell me on what I have to do the conditional split? Can you show me any example to let me understand better?

just add a conditional split after the merge join to split the rows. You can evaluate if the the columnX is null or not; if it is null means there was not a match.

SabAlo wrote:

When you say:

“…BTW, Have you loked at the Looukup transformation instead?”

I tell you:

In the package both the two sets of rows (LT pipeline and RT pipeline) doesn't came from a datasource but they are a result of an intermediate elaboration of data read at the beginning of package.

Thanks again!

Fair enough.

|||

Hi,

I followed the suggestion to consider the columnA in the output results and it is working! I test the its value and it is really null if it doesn't match the merge criteria.

As regard the testing of the other column (B), my problem is that could contain null value and should be imppossible to distinguish one record from the other.

Anyway, thanks for the hint!!

Monday, February 13, 2012

about GetODBCFieldInfo (MFC)

I use ODBC to operate SQL Server 2000. I want to know the data type for each
column in a table. But for image data, text , varchar... , all the return
value are negative.
In addition, how can I realize a table structure copy with ODBC ?
Any suggestion?
Thanks.
UHow about using SQLColumns

about GetODBCFieldInfo (MFC)

I use ODBC to operate SQL Server 2000. I want to know the data type for each
column in a table. But for image data, text , varchar... , all the return
value are negative.
In addition, how can I realize a table structure copy with ODBC ?
Any suggestion?
Thanks.UHow about using SQLColumns