Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Thursday, March 29, 2012

CRI Designer Adornment class - host WinForms controls?

Hi,

I'm developing a CRI and in design mode I would like to have some controls on my adornment windows. Is there a way to use WinForms controls here instead of redefining the wheels...?

Thomas

Sorry, using Winforms controls in adornments is not supported.

-Albert

|||

So what do you propose for more complicated UIs? The properties dialog as the only solution?

Thomas

|||

That is one possible solution. You don't have much flexibility to dynamically change the appearance of your adornment, but you can intercept mouse movements and clicks. You can create a dialog that is invoked by clicking in the adornment.

-Albert

CRecordset consumes SQL Server Memory

I have an MFC app with a thread that uses a ODBC consumer class to access a
SQL server. When I write the code different ways I get different results an
d
don't know why.
Example 1:
threadFunc()
{
CtblMyTable myRecordset(NULL);
while( !kill )
{
myRecordset.Open();
myRecordset.Close();
}
}
Example 2:
threadFunc()
{
while( !kill )
{
CtblMyTable myRecordset(NULL);
myRecordset.Open();
myRecordset.Close();
}
}
Example 3:
threadFunc()
{
while( !kill )
{
CDatabase db;
CtblMyTable myRecordset(&db);
myRecordset.Open();
myRecordset.Close();
db.Close();
}
}
Example 1 uses up no memory in the SQL server. Example 2 consumes memory in
the SQL server at a fast rate and eventually my "stolen pages" start to
increment. Example 3 consumes memory at a much slower rate, like less than
a
tenth of the rate.
Can anyone explain why the location of the declaration or the declaration of
a CDatabase object affects memory usage in my SQL Server? Is there a way
that I can get the memory to clean up in SQL Server? I eventually crash
every few ws because I run out of memory in SQL Server and I think it has
something to do with the fact that most of my code is not like example 1.
ThanksHi
Passing NULL to your recordset constructor to have a CDatabase object
constructed and connected for you automatically each time it is called. This
is probably not getting cleaned up until your procedure exits and the
Recordset is distroyed. Having a single CDatabase object for your
application will be more efficient.
John
"Jason Wood" <jason.wood@.woodtc.com.nospam> wrote in message
news:7918D6CB-4E57-4722-BB9A-64BBD9F6C6DE@.microsoft.com...
>I have an MFC app with a thread that uses a ODBC consumer class to access a
> SQL server. When I write the code different ways I get different results
> and
> don't know why.
> Example 1:
> threadFunc()
> {
> CtblMyTable myRecordset(NULL);
> while( !kill )
> {
> myRecordset.Open();
> myRecordset.Close();
> }
> }
>
> Example 2:
> threadFunc()
> {
> while( !kill )
> {
> CtblMyTable myRecordset(NULL);
> myRecordset.Open();
> myRecordset.Close();
> }
> }
>
> Example 3:
> threadFunc()
> {
> while( !kill )
> {
> CDatabase db;
> CtblMyTable myRecordset(&db);
> myRecordset.Open();
> myRecordset.Close();
> db.Close();
> }
> }
>
> Example 1 uses up no memory in the SQL server. Example 2 consumes memory
> in
> the SQL server at a fast rate and eventually my "stolen pages" start to
> increment. Example 3 consumes memory at a much slower rate, like less
> than a
> tenth of the rate.
> Can anyone explain why the location of the declaration or the declaration
> of
> a CDatabase object affects memory usage in my SQL Server? Is there a way
> that I can get the memory to clean up in SQL Server? I eventually crash
> every few ws because I run out of memory in SQL Server and I think it
> has
> something to do with the fact that most of my code is not like example 1.
> Thanks

Monday, March 19, 2012

creating SQL statement

Alright, so let me explain the details first.

I have two tables. One is the default aspnet_users table that themembership class builds. that has GUID, username, lowereduser, and such.

then I have another table called "UserSkills". That stores the GUID of the member, then the skills they have. so in that table i have. userID as GUID, then about 12 languages in 'bit' format.. (thats becuase in the webpage when they fill out there profile, all these are checkboxes. Basically all of the info is here http://www.listofcoders.com/profile.aspx?name=fenixsn. so there are a couple of bit fields, 1 text, and couple of varchars.

anways, so i wanna build a powerful search thingy. where the users have the option to search a user that only does for ex say php, asp, asp.net. and is from location "Canada". ok so when they fill out the info, I want my SQL statement to do the following


search the userskills table for the required fields. there might be more then 1 person that has the same profile, but different GUID. and then maybe using "Join" or another sql statement, grab there username, and last activity date from the users table that memberhship createes.


so in short, how do i make a dynamic sql statement.

anyone can help me out here?|||anyone help me pleas|||

Hi masfenix,

If you're trying to search according to the user input, you will need to use a WHERE clause after SELECT statement.

SELECT * FROM Table1 WHERECountry=@.Country ANDSkill=@.Skill

If the skill is not in the same table, you can use a JOIN

SELECT *,Skill.SkillName FROM Table1 LEFT OUTER JOIN Skill ON Table1.SkillID = Skill.SkillID WHERE .....

In your page code, pass the criterias through parameters and the expected result will be returned.

|||

Hi, I wanna make a SPROC out of this.

how do I write the select statement then RETURN THE DATA (there could be more then 1 row returend).

and how do i read that data and put it in a gridview?

Creating SQL Classes ?

I am trying to create a class that will interact with a SQL Server database
I have made up but having a few issues with it.
The basic code is:
Class DatabaseMethods
{
Public:
DatabaseOpen();
DatabaseCreate();
Private:
SqlConnection conn;
};
When compiling (VS C++ 2005) , it won't let me declare 'SqlConnection conn;'
Is there a way around this ?
Cheers
Pete
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
-->>>>>>http://www.NewsDemon.com<<<<<<--
Unlimited Access, Anonymous Accounts, Uncensored Broadband AccessShould you fully denote the namespace where SQLConnection resides -or add a
'Using System.Data.SQLClient' to the class? How else would this class know
where/how to locate the SQLConnection object?
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"MyMail" <peter.moscatt@.gmail.com> wrote in message
news:44960c8f$0$30230$b9f67a60@.news.newsdemon.com...
>I am trying to create a class that will interact with a SQL Server database
>I have made up but having a few issues with it.
>
> The basic code is:
>
> Class DatabaseMethods
> {
> Public:
> DatabaseOpen();
> DatabaseCreate();
> Private:
> SqlConnection conn;
> };
>
> When compiling (VS C++ 2005) , it won't let me declare 'SqlConnection
> conn;'
>
> Is there a way around this ?
>
> Cheers
> Pete
>
>
> --
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
> -->>>>>>http://www.NewsDemon.com<<<<<<--
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access|||G'Day Arnie,
Thanks for the guide.
I did what you asked (see code below)
// ......... MyHeader.h .........
using namespace System;
using namespace System::Data;
using namespace System::Data::SqlClient;
class DaabaseMethods
{
using System::Data::SqlClient;
public:
void OpenDatabase();
void CreateDatabase();
};
I would have throught because I had already declared
'System::Data::SqlClient' at the top of the header the class should
have seen it.
But anyway, I compiled it and got the following:
error C2886: 'System::Data::SqlClient' : symbol cannot be used in a
member using-declaration
So, what ya reckon '
Pete
"Arnie Rowland" <arnie@.1568.com> wrote in message
news:%23Vq0ky2kGHA.1324@.TK2MSFTNGP04.phx.gbl...
> Should you fully denote the namespace where SQLConnection
> resides -or add a 'Using System.Data.SQLClient' to the class? How
> else would this class know where/how to locate the SQLConnection
> object?
> --
> Arnie Rowland, YACE*
> "To be successful, your heart must accompany your knowledge."
> *Yet Another certification Exam
>
> "MyMail" <peter.moscatt@.gmail.com> wrote in message
> news:44960c8f$0$30230$b9f67a60@.news.newsdemon.com...
>
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
-->>>>>>http://www.NewsDemon.com<<<<<<--
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access|||The USING statement has to be outside (and before) the class definition
code -you are correct that the header is where it belongs.
I'm not a C++ person, you need to direct this question to a group that deals
with C++.
Regards,
Arnie Rowland, YACE*
"To be successful, your heart must accompany your knowledge."
*Yet Another certification Exam
"MyMail" <peter.moscatt@.gmail.com> wrote in message
news:44971fa3$0$4190$b9f67a60@.news.newsdemon.com...
> G'Day Arnie,
> Thanks for the guide.
> I did what you asked (see code below)
> // ......... MyHeader.h .........
> using namespace System;
> using namespace System::Data;
> using namespace System::Data::SqlClient;
> class DaabaseMethods
> {
> using System::Data::SqlClient;
> public:
> void OpenDatabase();
> void CreateDatabase();
> };
> I would have throught because I had already declared
> 'System::Data::SqlClient' at the top of the header the class should have
> seen it.
> But anyway, I compiled it and got the following:
> error C2886: 'System::Data::SqlClient' : symbol cannot be used in a member
> using-declaration
>
> So, what ya reckon '
> Pete
>
> "Arnie Rowland" <arnie@.1568.com> wrote in message
> news:%23Vq0ky2kGHA.1324@.TK2MSFTNGP04.phx.gbl...
>
> --
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
> -->>>>>>http://www.NewsDemon.com<<<<<<--
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access|||Xref: TK2MSFTNGP01.phx.gbl microsoft.public.sqlserver.programming:610013
No worries Arnie... thanks for the help anyway.
Pete
On Mon, 19 Jun 2006 16:37:01 -0700, "Arnie Rowland" <arnie@.1568.com>
wrote:

>The USING statement has to be outside (and before) the class definition
>code -you are correct that the header is where it belongs.
>I'm not a C++ person, you need to direct this question to a group that deal
s
>with C++.
>Regards,
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
-->>>>>>http://www.NewsDemon.com<<<<<<--
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Sunday, March 11, 2012

Creating Reports Using SQL QUERY ANALYZER

I am a student of the University of Phoenix. In My SQL class I was unsuccessful in creating a report using basic SQL commands using the SQL Query Analyzer version 8.00.760.

I am using a version of Microsoft SQL Server 2000 Sold to me by the college. The Disk 1 said SQL Server 2000 Developer Edition. Disk 2 said SQL Server 2000 service pack 3a. The Third Disk Says SQL Server 2000 Reporting Services.

Since I am learning SQL on this platform I wanted to create reports using the SQL Query Analyzer. So how do I create reports using Basic Commands. This is what I have so far.

CREATE TABLE ACCOUNTS
(
Account_Number INT NOT NULL PRIMARY KEY,
Long_Description VarChar(500) NOT NULL,
Short_Description VarChar(500)NOT NULL,
Balance Money NULL,
);

Once I Imported the data from an excel file. I created a view.

CREATE VIEW Account_Report
(Account, Descript, Identifier, Balance) AS
SELECT Account_Number, Long_Description, Short_Description, Balance
FROM Accounts

Then from this view I pulled my report, and the best I could come up with was

SELECT *
FROM Account_Report
ORDER BY Account COMPUTE SUM(Balance)

I want to do more. Such as Create headers, Justify Left right or center, FORMAT Money Column to only have 2 decimal places, Trim the extra space on the right side of the columns, rename the columns, and scroll down 20 lines at a time.

Any help would be appreciated. My class is over so this is realy all just for the furthering of my own knowlegde.

Noctechie

if you are up to making professional reports you have make use of the reporting services

now for your needs, you have to integrate function in your select statement

here some to start with

String Functions

The following table contains samples of string functions. For more information, see String Functions and Using String Functions.

Function

Description

Example

LCASE( )1,
LOWER( )

Converts strings to lowercase

SELECT UPPER(substring(lname, 1, 1)) +

LOWER(substring (lname, 2, 99))

FROM employee

Displays a last name after the first character is converted to uppercase and the remaining characters to lowercase.

LTRIM( )

Removes leading spaces from a string

SELECT stor_name, LTRIM(stor_address)

FROM stores

Displays an address column after extraneous spaces are removed from the front.

SUBSTRING( )

Extracts one or more characters from a string

SELECT SUBSTRING(phone,1,3)

FROM employee

Displays the first three characters (the area code) of a phone number.

UCASE( )1,
UPPER( )

Converts strings to uppercase

SELECT * FROM employee

WHERE UPPER(lname) = 'SMITH'

Converts the contents of the lname column to uppercase before comparing them to a specific value (avoids mismatches if the search is case sensitive). For details about case sensitivity in SQL Server, see Query Designer Considerations .

1 If calling as an ODBC function, use syntax such as: { fn LCASE(text) }.

Date Functions

The following table contains samples of date functions. For more information, see Date and Time Functions.

Function

Description

Example

DATEDIFF( )

Calculates an interval between two dates.

SELECT fname, lname, hire_date

FROM employee

WHERE DATEDIFF(year, hire_date, getdate()) > 5

Locates all employees hired more than five years ago.

DATEPART( )

Returns the specified portion of a date or datetime column, including the day, month, or year.

SELECT DATEPART(year, hire_date)

FROM employee

Displays only the year in which an employee was hired (not the full date).

CURDATE( )1,
GETDATE( )
or DATE( )

Returns the current date in datetime format. This function is useful as input for many other date functions, such as calculating an interval forward or backward from today.

SELECT order_id

FROM orders

WHERE order_date = GETDATE()

Displays orders placed today.

1 If calling as an ODBC function, use syntax such as: { fn CURDATE() }.

Mathematical Functions

The following functions are typical of those available in many databases. Refer to Mathematical Functions for more information.

Note You can use the aggregate functions AVG( ), COUNT( ), MAX( ), MIN( ), and SUM( ) to create averages and totals in your report. For details, see Summarizing and Grouping.

Function

Description

Example

ROUND( )

Rounds a number off to the specified number of decimal places

SELECT ROUND(qty * (price * discount), 2)

FROM sales

Displays a total price based on a discount, then rounds the results off to two decimal places.

FLOOR( )

Rounds a number down to the nearest (smallest) whole number

UPDATE titles

SET price = FLOOR(price)

Rounds all prices in the titles table down to the nearest whole number.

CEILING( )

Rounds a number up to the nearest whole number

INSERT INTO archivetitle

SELECT title, CEILING(price)

FROM titles

Copies the title and the price (rounded up to the nearest integer) from the titles table to the archivetitle table.

System Functions

The following functions are typical of those available in many databases. For more information, see System Functions.

Function

Description

Example

DATALENGTH( )

Returns the number of bytes used by the specified expression

SELECT DATALENGTH(au_lname + ', '

+ au_fname)

FROM authors

Lists the number of bytes required for the combination of last and first names.

USER( )1,
USER_NAME( )

Returns the current user name

SELECT company_name, city, phone

FROM customers

WHERE salesperson = USER_NAME()

Creates a list of customers for the salesperson who runs the query.

1 If calling as an ODBC function, use syntax such as: { fn USER() }.

Other Functions

The following functions illustrate utility functions available in many databases. For more information, see Functions.

Function

Description

Example

CONVERT( )

Converts data from one data type into another. Useful to format data or to use the contents of a data column as an argument in a function that requires a different data type.

SELECT 'Hired: ' + CONVERT(char (11),

hire_date)

FROM employee

Displays a date with a caption in front of it; the CONVERT( ) function creates a string out of the date so that it can be concatenated with a literal string.

SOUNDEX( )

Returns the Soundex code for the specified expression, which you can use to create "sounds like" searches.

SELECT au_lname, au_fname

FROM authors

WHERE SOUNDEX(au_fname) = 'M240'

Searches for names that sound like "Michael".

STR( )

Converts numeric data into a character string so you can manipulate it with text operators.

SELECT str(job_id) + ' ' +

str(job_lvl)

FROM employee

Displays the job_id and job_lvl columns (both numeric) in a single string.

Thursday, March 8, 2012

Creating property get and set clauses based on a table or sp

Is there a way to automatically (wizard?) to create the get and set clauses of a class based on a SQL table or sp? I need to wrap a number of tables and sp into classes to use them in an ASP.net application and it's rather tedious to do type each one.

What I would like is something that I could point at a table and have it create a class and the get and set properties. I could save that as a class and use it in the program.
eg. Point to a table people.
Results would be
Class People
property FirstName()
get

set

...

Aim.You can create a strong typed data set.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcongeneratingstronglytypeddataset.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingannotationswithtypeddataset.asp

It will generate the class based on a xml schema, and you can easily build a schema by drag and dropping your table on the xml scheman designer.|||Thanks for the reply, I appreciate your time. However, I am not sure that it is what I want. Maybe I am missing the point.

I want to create a class based on a table. The class would have a local variable and a property get/set clause for each field in the table.
eg if the table were
FirstName
LastName
Middle Initial

I would end up with a class that looked something like

class Name
dim fname as string
dim lname as string
dim mi as string

Public Property FirstName() As String
Get
Return fname
End Get
Set(ByVal Value As String)
fname = Value
End Set
End Property

Public Property LastName() As String
Get
Return lname
End Get
Set(ByVal Value As String)
lname = Value
End Set
End Property
Public Property MiddleInitial() As String
Get
Return mi
End Get
Set(ByVal Value As String)
mi = Value
End Set
End Property

end class

If anyone knows how I can do this I would appreciate a hint or two.

Aim.|||You can do it yourself if you set your query analyzer output to text mode with space separators.


declare @.TABLE_NAME='Name'

print 'Class ' + @.TABLE_NAME + '
'

select 'dim _'+COLUMN_NAME+' as'
, CASE DATA_TYPE WHEN 'int' THEN 'Integer' ELSE 'string' END
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME=@.TABLE_NAME

select 'Public Property '+COLUMN_NAME+' As',
CASE DATA_TYPE WHEN 'int' THEN 'Integer' ELSE 'String' END, '
Get
Return _'+COLUMN_NAME+'
End Get
Set(ByVal Value As',
CASE DATA_TYPE WHEN 'int' THEN 'Integer' ELSE 'String' END,
')
_'+COLUMN_NAME+' = Value
End Set
End Property

'
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME=@.TABLE_NAME

print 'End Class'

|||Thanks for that. It's a cute solution. Maybe I can package that and make my own wizard.

Cheers

Aim.