Friday, December 8, 2006

VBA - Dynamic UserForms (Controls Created Dynamically)

Did you know that you can add and remove controls from a UserForm (also known as custom dialog boxes) at run-time? This means

that you can change your UserForms based on certain conditions that exist during the operation of your VBA project—you’re not

limited to the design of the UserForm that you created in the VBA designer!

Below is the sample code, this will create one checkbox control and one command button contol in runtime.

'Copy and paste the below code in one module and run the macro.
----------------------------------------------------------------
Sub CreateControls()
Dim CtrlChk As MSForms.CheckBox
Dim CtrlCMD As MSForms.CommandButton
Dim CtrlObj As New clmodCHK

'Load UserForm1
With UserForm1 'Create an user form(userform1) to display controls.
' Set object for CheckBox Control
Set CtrlChk = .Controls.Add("Forms.CheckBox.1", "ChkBox1") '
CtrlChk.Top = 50
CtrlChk.Left = 50
CtrlChk.WordWrap = False
CtrlChk.Caption = "Checkbox Created at Runtime"
Set CtrlObj = Nothing
' Set CtrlObj.chkCtrl = CtrlChk
'Command button
Set CtrlCMD = .Controls.Add("Forms.CommandButton.1", "cmdCB1")
CtrlCMD.Top = 100
CtrlCMD.Left = 50
CtrlCMD.WordWrap = False
CtrlCMD.AutoSize = True
CtrlCMD.Caption = "CommandButton Created"
Set CtrlObj = Nothing
Set CtrlObj.cmdCtrl = CtrlCMD
End With
End Sub
----------------------------------------------------------------

Timer Process (Excel Macro)

To start the process, use a procedure called StartProcess, similar to the code shown below.

Sub StartProcess()
Application.OnTime earliesttime:=Now + TimeValue("00:01:00"),procedure:="Call_Timer", schedule:=True
End Sub


This stores the date and time 1 minute from the current time in the RunWhen variable, and then calls the OnTime method to instruct Excel when to run the Call_Timer procedure.

Since is a string variable containing "Call_Timer", Excel will run that procedure at the appropriate time. Below is a sample procedure:

Sub Call_Timer()
StartTime
End Sub

Note : that the last line of Call_Timer calls the StartProcess procedure. This reschedules the procedure to run again. And when the Call_Timer procedure is called by OnTime the next time, it will again call StartProcess to reschedule itself. This is how the periodic loop is implemented.

Below is a procedure called StopProcess which will stop the pending OnTime procedure.

Sub StopProcess()
On Error Resume Next
Application.OnTime earliesttime:=Now + TimeValue("00:01:00"),procedure:=Call_Timer, schedule:=False
End Sub

Monday, December 4, 2006

Sql Queries

Questions

[use NorthWind Database]
1. Select the Order Details of all the orders ordered by the Customer whose CustomerID='ANATR'
2. Select the number of Orders for the Product whose ProductID='12'
3. Select the CustomerID, who has placed the maximum number of Orders
4. Select the maximum Freight Charge for a Ship from 'Brazil'
5. Display the First Name of the Reporting Manager of the Employee whose EmployeeID='9'
6. Select the Employee who has the maximum Service Years
7. Select the distinct Countries of the Customers for which the Employee serves whose EmployeeID='5'.
8. Find the Seniormost Employee (like CEO) from the Employee Table
9. Display the OrderDetails of the Orders which are placed in the October month of 1997
10. Display the sum of the Freight Charges for each of the Employee from the Orders Table

Answers


1.Select * from [Order Details] od,Orders o where o.OrderID=od.OrderID and CustomerID='ANATR'
2.select count(ProductID) from [Order Details] od where ProductID=12
3.select customerID from orders ta group by customerid having count(CustomerID) >= ALL (select count(customerid) cou from orders group by customerid)
4.select max(Freight) from Orders where ShipCountry='Brazil'
5.select e2.firstname from employees e1,employees e2 where e2.employeeID=e1.ReportsTo and e1.EmployeeId=9
6.select firstname from employees where hiredate=(select min(hiredate) from employees)
7.select distinct(customers.country) from customers,orders,employees where customers.customerid=orders.customerid and orders.employeeid=employees.employeeid and employees.employeeid=5
8.select firstname from employees where ReportsTo is null
9.select * from [Order details],Orders where Orders.OrderId=[Order details].OrderId and Orders.OrderDate between '1997-10-01' and '1997-10-31'
10.select sum(freight) from Orders Group by employeeId order by employeeID

5000 + Sample Resumes for fresher & experienced

Hi friends,I have got this very much useful information. I would like to share with all.Are you confused what to write in a resume being a fresher? OR How to improve your resume being an experienced person?Here is my personal links which I use. You will find more then 5000+ resume samples in all the links below. So why wait… Start making / improving.
resume.monster.com
susanireland.com
jobweb.com
resume-resource.com
resume-resource.com
career.vt.edu
resumesandcoverletters.com
Many resume formats on left side of the page
.Download Resume formats
careerperfect.com
For Freshers quintcareers.com
I hope this is useful to all
bestsampleresume.com
careerperfect.com
For Freshers
quintcareers.com
I hope this is useful to all.

BizTalk Server in a nut shell

BizTalk Server is built completely around the .NET Framework and Microsoft Visual Studio® .NET. It also has native support for communicating through Web services, along with the ability to import and export business processes described in BPEL(Business Process Execution Language).It should be in the following scenarios:

-- Connecting applications within a single organization, commonly referred to as enterprise application integration (EAI)-- Connecting applications in different organizations, often called business-to-business (B2B) integration-- Connecting applications within a single organization, commonly referred to as enterprise application integration (EAI)-- Connecting applications in different organizations, often called business-to-business (B2B) integrationFor further details luk into http://biztalkblogs.com/
ample of articles and resources are available for BizTalk

Save an Image in a SQL Server Database

Most of the web applications have a lot of images used in it. These images are usually stored in a web server folder and they are accessed by giving the relative path to the file with respect to the root folder of the website. .Net being the platform for distributed application now, ASP.Net can be used to store images that are small to be stored in a database like SQL Server 2000 and later versions. For this purpose the SQL Server database provides a data type called “image” which is used to store images in the database.
To access these images stored in the database we will be using the ADO.Net classes. To find out how to insert and retrieve an image in to the SQL Server database, you can create a .aspx page which can have a HTMLInputFile control which is used to select the image file that is to be saved in the database. You can also create a textbox control in which you can add the image name or some comment or an image id for the image saved. Use a button control to upload the image to the database. Namespaces like System.Data.SqlClient, System.Drawing, System.Data, System.IO, and System.Drawing.Imaging are used in this task.
In the OnClick property of the button you can write the following code to upload an image to the database.
// create a byte[] for the image file that is uploaded
int imagelen = Upload.PostedFile.ContentLength;
byte[] picbyte = new byte[imagelen];
Upload.PostedFile.InputStream.Read (picbyte, 0, imagelen);
// Insert the image and image id into the database
SqlConnection conn = new SqlConnection (@"give the connection string here...");
try {
conn.Open ();
SqlCommand cmd = new SqlCommand ("insert into ImageTable " + "(ImageField, ImageID) values (@pic, @imageid)", conn);
cmd.Parameters.Add ("@pic", picbyte);
cmd.Parameters.Add ("@imageid", lblImageID.Text); cmd.ExecuteNonQuery (); }
finally { conn.Close (); }

You can also write the above code in a function and call that function in the OnClick event of the upload button. The code given above performs the following steps in the process of inserting an image into the database.
1. Get the content length of the image that is to be uploaded
2. Create a byte[] to store the image
3. Read the input stream of the posted file
4. Create a connection object
5. Open the connection object
6. Create a command object
7. Add parameters to the command object
8. Execute the sql command using the ExecuteNonQuery method of the command object
9. Close the connection object
To retrieve the image from the SQL Database you can perform the following steps.
1. Create a MemoryStream object. The code can be something like, MemoryStream mstream = new MemoryStream ();
2. Create a Connection object
3. Open the connection to the database
4. Create a command object to execute the command to retrieve the image
5. Use the command object’s ExecuteScalar method to retrieve the image
6. Cast the output of the ExecuteScalar method to that of byte[] byte[] image = (byte[]) command.ExecuteScalar ();
7. Write the stream mstream.Write (image, 0, image.Length);
8. Create a bitmap object to hold the stream Bitmap bitmap = new Bitmap (stream);
9. Set the content type to “image/gif” Response.ContentType = "image/gif";
10. Use the Save method of the bitmap object to output the image to the OutputStream. bitmap.Save (Response.OutputStream, ImageFormat.Gif);
11. Close the connection
12. Close the stream mstream.Close();
Using the above steps you can retrieve and display the image from the database to the web page.
You can use these algorithms and take advantage of the “image” data type available in the SQLServer 2000 database to store small images that correspond to a particular record in the table of the database. This method of storing avoids the tedious task of tracking the path of the web folder if the images are stored in a web folder.

Source : Balaji

WebDesigning Ideas

Whenever a web designer gets a web design project, he or she will require to take a step back and go through the research process in order to complete the job. The research process is a tedious process, it determines how well, and successful will the result of your web design. Ideas for web design will share with you how to go through that research process smoothly and obtain results.
One fine day, you received a call from some client and he requests you to design a website for his company. Over the phone, he briefly tells you what his company is about and asks about the prices, you then fixed an appointment with him for discussion. You will probably get excited about it and starts to get more details of the company by checking them on Google, and thinks about some prelim ideas for the website. At this stage, your research process has already started.
RETREIVING THE DETAILS:
After meeting up with the client, you get a lot of details that will assist you in your design process. This details applies even when you are designing a personal website.
1. Nature of the Company
2. Client Preferences (Example websites?)
3. Target Audiences (kids? Young adults? Everyone in the world?)
4. Platform (Flash? Html? Php? Asp? ).net ebooks, .net tutorials , vb.net , c#.net , .net framework books, asp.net
By organizing these details, you get a bigger picture of:
1. What are you going to design?
2. What style of design are you approaching?
3. Whom you should design for?
4. How will your design work?
5. How will your design please both the audiences and the client in order to be successful?
DETERMINING THE STYLE:
With the information you have on hand, its time to determine the style. For a start, you should base on the client’s description of his company, his nature of the company to give a rough gauge on the design style. Examples below:
Example 1:
Web Hosting business >> High tech web design, sleek and professional design
Example 2:
Dolls and Toys business >> Kiddy, Girly, Colorful, Fun design
COLOR THEMES:
Having a good and suitable color theme on your web design will give users a pleasing experience while surfing through the web site you designed. One of the important techniques is to get a color chart from your local art store or use some color chooser tools to aid in your color selection. Your color theme will affect the mood and feel you want to create. Colors also have their own meanings. For example, white is clean, blue is cool and corporate, having a white and blue color theme gives you a clean and corporate web design. Orange and yellow are warm and friendly colors, Grey is cool, combining a Orange-Grey theme will give you a friendly and fun mood. Dark colors are also popular among many, because they easily matched other bright colors. A common match is using a black background and light colored text as a combination.
There are thousands and one meaning to choose your color theme. Whether your color theme turns out successful depends heavily on the first step “Determining the style” of your website.
PHOTOS & GRAPHICS:
After getting the colors done, its time to think about the graphics and images. As a graphic says a thousand words, it is good to think about how you want to approach this portion. Here are some recommendations you can try:
1. Stock photos – Some are free, some requires you to pay a certain amount before providing you with high resolutions image. If your client has the money and there are suitable photos he would like to use, this is the way to go. Searching in Google for “stock photos” will give you plenty of results on this.
2. Take your own photos – When budget is involve, usually the project will require you to take a relevant photos and use them as supporting images on the website. Having a mid-range camera should do the trick as images for website are all on low resolution. Seldom there is a chance for you to use an image more than 640 x 480 pixels.
3. Creating Graphics Images – A web design will always need custom-made graphics images. For example, icons for a Shoe section, button for submitting information. You will need some skills in creating the graphics of your needs, or you will feel stuck while designing. Consider looking for tutorials on creating certain effects, like rounded corners, Mac alike buttons, pattern backgrounds and more. Learn about vector graphics tool like Adobe Illustrator and Macromedia Fireworks. They can help you to create graphics, mockups and layout fast and efficiently. This will greatly aid in your next web design project.
INSPIRATION AND REFERENCES:
If you already have some inspiration on how to design the layout, great, but if you do not, consider looking at related websites for some references on how they are being done. A search in Google also reveals some websites of the same genre. You can also check out ready-made templatesas well. I am not teaching you to copy exactly, but as a new learner, you should take reference and see how they are being designed.
Why bother looking at them?
Reference sites will give you ideas on usability, color theme, ideas on relevant images, navigation, features and many more guides to work on your web design project. Always consider them as useful references to help you whenever you need inspiration and ideas for your web design. It is all about looking more, reading more and getting your eyes and brain more exposed to the web design styles. www.sitecritic.net has alot of website reviews by different web designers all over the world and is worth taking a look.

Troubleshooting Common IIS Errors

Debug Common IIS Errors

Want your C# Win Forms Applications to look like Windows XP buttons

Dear Friends,
Want your Applications to look like Windows XP buttons and so on...Justadd the following line of Code to achieve theming in your winform applicationsC#In the Application Initialization event And apply the System Property of Flat Style in the properties of the respective control.
{
Enter the following codeApplication.EnableVisualStyles();
Application.DoEvents();
Application.Run (New Form1);
}
VBPublic Shared Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()
End Sub
Thats it and your apps will have the look and feel like XP :)

Send Mail using CDONTS

CDO is microsoft inbuild component to send EMail,
To send a mail firts add a reference(Project-> Add Reference -> in the COM tab choose the microsoft CDO library)
then use the below code.

Dim oMsg As CDO.Message = New CDO.Message
oMsg.From = strFrom
oMsg.To = strTo
oMsg.Subject = strSub
strBody = "email"
oMsg.TextBody = strBody
oMsg.Send()
oMsg = Nothing

Using this tyou can send a mail with SMTP.