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.

Friday, November 24, 2006

Using the registry from a VB.Net application

Creating the demo project

If you want to build this demo yourself, start by creating a user interface looking like the image you see here. Don't forget that a complete demo is available for download at the end of this article.

At the top of the code in your form, you need to add the line to imports the namespace:

Imports Microsoft.Win32

Adding values to the registry

The code needed to create a key into the registry and place some values in it is very simple (this code can be placed into the Click event of a button):

Dim oReg As RegistryKey
oReg = Registry.LocalMachine.OpenSubKey("Software", True)
oReg = oReg.CreateSubKey("UTMagDemo")
oReg.SetValue(txtName.Text, txtValue.Text)
oReg.Close()

The code starts by opening the Software key of the HKEY_LOCAL_MACHINE registry hive. Notice that all the hives are available (LocalMachine and CurrentUser are probably the ones you will most often use). The second parameter means that you are opening this key and that you will later write in it.

Once the Software key is opened, the UTMagDemo sub key is created in it. If this key already exists, nothing happens. No exceptions are raised. The key content will remain untouched. Notice that you can create a complete hierarchy in a single call (ie oReg.CreateSubKey("UTMagDemo\\Level1\\Level2\\Level3") is correct). Don't ask me why all the backslashes are doubled. Even if you put only one, it will be working. Even a mix of single and double backslashes is working (according to my own tests). It may have something to do with C# since the backslash is an escape character in C# (but has no impact in VB.Net). If you find out why, drop me a line!

The next line adds a new value to the sub key just created. If you let the Name parameter empty (or you set it to Nothing), the value will be saved in the (Default) key name. If you provide a value for a name that exists, the value is simply replaced without warnings.

The last line is closing the key we opened.

Many exceptions may be triggered while trying to write to the registry. The most encountered are:

  • The user does not have permissions to create registry keys.
  • The key name cannot exceeds 255 characters
  • The key is closed.
  • The key is read-only.

Reading the value back

Many of the lines needed to read from the registry are the same as the ones we used to write:

Dim oReg As RegistryKey
Dim strValue As String
oReg = Registry.LocalMachine.OpenSubKey("Software\\UTMagDemo")
strValue = oReg.GetValue(txtName.Text, "DEFAULT-VALUE").ToString
MessageBox.Show(strValue, _
"Stored Registry Value", _
MessageBoxButtons.OK, _MessageBoxIcon.Information)
oReg.Close()

The code starts by opening the sub key we created in the previous sample. One thing you really need to check (and it is not done here – but it is done into the downloadable demo) is if the oReg is Nothing after the call of the OpenSubKey method. This indicates that the key you passed to the method does not exist. No exceptions are raised when this occurs.

The following line uses GetValue to retrieve the value with the Name parameter. Again, if you let the Name parameter empty (or you set it to Nothing), the value in the (Default) key name will be retrieved. If the Name does not exist, the default value (if you provide one) will be returned.

The last line is closing the key we opened.

any exceptions may be triggered while trying to write to the registry. The most encountered are:

  • The user does not have permissions to create registry keys.
  • The key name cannot exceeds 255 characters
  • The key is closed.
  • The key is read-only.

Wiping out our stuff

The Delete method has 3 flavors:

  • DeleteValue deletes a single value (using the Name parameter to specify which one to delete).
  • DeleteSubKey deletes a complete key and all the values it contains in a single shot (but raises an exception if it contains sub keys).
  • DeleteSubKeyTree deletes a complete key and all the values it contains as well as all sub keys in a single shot. The code I use for this demo is the following:
Dim oReg As RegistryKey
oReg = Registry.LocalMachine.OpenSubKey("Software", True)
oReg.DeleteSubKey("UTMagDemo")
oReg.Close()

Retrieving file type of a file extension

This other example shows how to retrieve the file type from a file extension.

Dim oReg As RegistryKey
Dim strIndexerKey As String
Dim strType As String
'Opens the key to retrieve the class name
oReg = Registry.ClassesRoot.OpenSubKey(txtFileExtension.Text)
If oReg Is Nothing Then
MessageBox.Show("The file extension " & _
txtFileExtension.Text & _
" is unknown.", _
"File Type", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information)
Exit Sub
End If
strIndexerKey = oReg.GetValue("").ToString
'Opens the class name to retrieve the file type
oReg = Registry.ClassesRoot.OpenSubKey(strIndexerKey)
strType = oReg.GetValue("", "").ToString
MessageBox.Show("The file extension " & _
txtFileExtension.Text & _
" is a " & strType, _
"File Type", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information)
'Close the registry keys.
oReg.Close()

Wednesday, November 22, 2006

XML Integration

What is XML?
What is the version information in XML?
What is ROOT element in XML?
If XML does not have closing tag will it work?
Is XML case sensitive?
What’s the difference between XML and HTML?
Is XML meant to replace HTML?
Can you explain why your project needed XML?
What is DTD (Document Type definition)?
What is well formed XML?
What is a valid XML?
What is CDATA section in XML?
What is CSS?
What is XSL?
What is Element and attributes in XML?
Can we define a column as XML?
How do we specify the XML data type as typed or untyped?
How can we create the XSD schema?
How do I insert in to a table which has XSD schema attached to it?
What is maximum size for XML datatype?
What is Xquery?
What are XML indexes?
What are secondary XML indexes?
What is FOR XML in SQL Server?
Can I use FOR XML to generate SCHEMA of a table and how?
What is the OPENXML statement in SQL Server?
I have huge XML file which we want to load in database?
How to call stored procedure using HTTP SOAP?
What is XMLA ?

Basic .NET and ASP.NET interview questions

  1. Explain the .NET architecture.
  2. How many languages .NET is supporting now? - When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.
  3. How is .NET able to support multiple languages? - a language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
  4. How ASP .NET different from ASP? - Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.
  5. Resource Files: How to use the resource files, how to know which language to use?
  6. What is smart navigation? - The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
  7. What is view state? - The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
  8. Explain the life cycle of an ASP .NET page.
  9. How do you validate the controls in an ASP .NET page? - Using special validation controls that are meant for this. We have Range Validator, Email Validator.
  10. Can the validation be done in the server side? Or this can be done only in the Client side? - Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
  11. How to manage pagination in a page? - Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
  12. What is ADO .NET and what is difference between ADO and ADO.NET? - ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.

Tuesday, November 21, 2006

inviting-dotnet-people

Hai guys,I am Arunachalam. Working as developer in Gl infotech. I am doing my projects in ASP.net, C#, SQL Server2000 & MS Access. Am inviting people who want to share their ideas & their doubts in dotnet & SQL Server.Lets have passion about Dotnet.

Regards,

Arun