Technology, Art, Solution, Tips, Multimedia, How To, What Is, Programming, Software, Freelance
Oct 29, 2007
Using Microsoft Report Viewer
1. add in a list.
2. add in table
3. drag data from data source to table
Dim voucher As New Voucher
DataGridView1.DataSource = voucher.FillVoucherHeader
DataGridView1.AutoResizeColumns()
DataGridView2.DataSource = voucher.FillVoucherItems
DataGridView2.AutoResizeColumns()
DataGridView3.DataSource = voucher.FillVoucherTotal
DataGridView3.AutoResizeColumns()
Me.VoucherTotalTableAdapter.Fill(Me.cpvdbDataSet.VoucherTotal)
Me.VoucherItemTableAdapter.Fill(Me.dsCheque.VoucherItem)
Me.VoucherHeaderTableAdapter.Fill(Me.dsCheque.VoucherHeader)
Me.ReportViewer1.RefreshReport()
Using VBC Command Line Compiler
Just recall back Java Learning during university lab.
Let's try:
-
From the Start menu, click on the Accessories folder, and then open the Windows Command Prompt.
-
At the command line, type vbc.exe /imports:Microsoft.VisualBasic,System sourceFileName and then press ENTER.
For example, if you stored your source code in a directory called SourceFiles, you would open the Command Prompt and type cd SourceFiles to change to that directory. If the directory contained a source file named Source.vb, you could compile it by typing vbc.exe /imports:Microsoft.VisualBasic,System Source.vb.
- To compile with reference file:
vbc /reference:metad1.dll,metad2.dll /out:out.exe input.
Oct 28, 2007
Enable Windows Vista Administrator Account
Introduction
If for whatever reason you must login Windows Vista with the Administrator account this guide will show you how it’s done.
Warning: Running as Administrator in Windows Vista bypasses all security (UAC) and is NOT recommended. If you decide to use the Administrator account don’t complain when you start having problems.
Enable the Administrator Account
- Open the command prompt with Administrative privileges by opening the Start Menu, type cmd in the search box, and then press Ctrl+Shift+Enter to open cmd with admin rights.
- Type the following in the command prompt and press Enter after:
net user administrator /active:yes - Restart your computer and logon as Administrator.
Note: You might want to set a password for the administrator’s account for at least a little protection.
Disable the Administrative Account
To disable the Administrative account run the Net User command demonstrated above while logged on an account with administrative privileges but not as the Administrator account and replace yes with no.
or
Disable the User Account
To disable the user account run the Net User command demonstrated above while logged on an account with user privileges but not as the Administrator account and replace yes with no.
-------------------------------------------------------------------------------------------
Here is another way!
Remember that cute "Administrator" account you see when you login to safe mode in XP? That's the built-in administrator account that's installed by default, and disabled by default too, after a little digging-in I made this tutorial that'll let you enable and use this account in normal mode, and with a little other tweak, enjoying an XP-like administrator experience, while UAC is left ON (or off, it doesn't matter), but with no prompts or right clicks.
For Windows Vista Ultimate/Business/Enterprise:
1- Click Start, and type "secpol.msc" in the search area and click Enter.
(You may receive a prompt from UAC, approve/login and proceed)
2- In the left list, choose "Local Policies", then "Security Options"
3- Set "Accounts: Administrator account status" to Enabled.
4- Set "User Account Control: Admin Approval Mode for the Built-in Administrator account" to Disabled.
For Windows Vista Home Basic/Home Premium:
1- Click Start, and type "cmd" in the search area, right click on "Command Prompt" and select 'Run as Administrator".
2- In the command prompt type "net users Administrator /active:yes" (Note the capital "A" in Administrator) and press Enter, you will get a confirmation as "The command completed successfully".
3- Click Start, and type "regedit" in the search area and click Enter, navigate to: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]Double click on "FilterAdministratorToken" and set it to "0"
*************************************
Now log-off, and you'll see new account named "Administrator" is available, click on it to login.
Now you are the master of your domain! I recommend if you're going to use this method is to apply it as soon as you do a fresh install of Windows, so you can simply delete whatever administrator you've created in the setup process, and make this one the "real" administrator for your PC, also you can rename this new admin account or change its password like any other account from "User Accounts" in the Control Panel.
A last note/disclaimer:
Please note that disabling UAC and using the built in Adminstrator account will also disable IE7 "Protected Mode", fore more information and a work around please see this post.
Please apply this procedures only if you know what you're doing. Disabling security features in the operating system is not something recommended to the average Joe, and for sure I won't be held accountable for any damaging happens to your system or files resulting from running a full administrator account all the time.
Special thanks to:
- Farstrider for providing the location of the relevant register keys that made applying this method to the home versions of Vista possible!.
- bradavon for his comment/solution of IE7 protected mode.
Oct 19, 2007
Connection Strings
SQL Server 2005
| SQL Native Client ODBC Driver | ||
| 1. Standard security | ||
| ||
| ||
| 2. Attach a database file on connect to a local SQL Server Express instance | ||
| ||
| ||
| 3. Attach a database file, located in the data directory, on connect to a local SQL Server Express instance | ||
| ||
| ||
-----------------------------------------------------------------------------------------------
SQL Native Client OLE DB Provider
| 1. Standard security | ||
| ||
| ||
| 2. Trusted connection | ||
| ||
| ||
| 3. Encrypt data sent over network | ||
| ||
| 4. Attach a database file on connect to a local SQL Server Express instance | ||
| ||
| ||
5. Attach a database file, located in the data directory, on connect to a local SQL Server Express instance | ||
| ||
| ||
------------------------------------------------------------------------------------------------
| SqlConnection (.NET) | ||
| 1. Standard Security | ||
| ||
| ||
| 2. Standard Security alternative syntax | ||
This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.
| ||
| 3. Trusted Connection | ||
| ||
| 4. Trusted Connection from a CE device | ||
| Often a Windows CE device is not authenticated and logged in to a domain. To use SSPI or trusted connection / authentication from a CE device, use this connection string. | ||
| ||
| ||
| 5. Connect via an IP address | ||
| ||
| ||
| 6. Attach a database file on connect to a local SQL Server Express instance | |||||||||||||||||||
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes; | |||||||||||||||||||
| |||||||||||||||||||
Using CDO Email Encoding
astrRecipientEmailAddress, _
astrCCEmailAddress, _
astrBCCEmailAddress, _
astrSenderEmailAddress, _
astrEmailSubject, _
astrEmailText)
'Dimension local variables
Dim objCDOMail
'Create Server Object
Set objCDOMail = Server.CreateObject("CDO.Message")
objCDOMail.From = astrSenderEmailAddress
objCDOMail.To = astrRecipientEmailAddress
objCDOMail.Subject = astrEmailSubject
objCDOMail.TextBody = astrEmailText
'this is the encoding part if you are using text as mail content
objCDOMail.BodyPart.Charset = "utf-8"
objCDOMail.TextBodyPart.Charset = "utf-8"
'this is the encoding part if you are using html as mail content
'create a proper html tag
'with Content-Type: text/html; charset=utf-8
objCDOMail.BodyPart.Charset = "utf-8"
objCDOMail.HtmlBodyPart.Charset = "utf-8"
'check whether to Copy or BCC this email
if len(astrCCEmailAddress) > 0 then
objCDOMail.CC = astrCCEmailAddress
end if
if len(astrBCCEmailAddress) > 0 then
objCDOMail.BCC = astrBCCEmailAddress
end if
objCDOMail.Send
end sub
MSSQL 2005 Backup and Restore SQL Syntax
---------------
RESTORE DATABASE myNewDb
FROM DISK = 'C:\Documents and Settings\Administrator\Desktop\family_backup.bak'
WITH MOVE 'myOldDb_Data' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\myNewDb.mdf',
MOVE 'myOldDb_Log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\myNewDb.ldf',
REPLACE
**Note:
If you are about to restore the old version sql2000 DB,
you can create a sql2005 db with the same name first,
change the DB Properties > Options > Capability Level > SQL2000 (80),
then you proceed with the above sql syntax
BACKUP DB
--------------
use [myNewDb]
BACKUP DATABASE [myNewDb] TO DISK = N'D:\Database Backup\myNewDb.bak'
WITH NOFORMAT, NOINIT, NAME = N'myNewDb-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
Oct 18, 2007
Runtime Web.config / App.config Editing
Web.config configuration files and app.config project item files, which get converted to "ExecutableName.exe.config" at build time, both support the convenient appSettings section with its own read method in the System.Configuration.ConfigurationSettngs class. The appSettings section stores element name / value pairs in the format:
You can store as many of these
I often read out my appSetting values into a NameValueCollection at runtime, which provides one-shot acess to the entire collection in memory:
NameValueCollection mySettings = System.Configuration.ConfigurationSettings.AppSettings;
string connStr = mySettings["connString"];
But what about being able to change, add, and save appSettings items while that app is running in response to user input or other actions, instead of just reading them out? Nada, Zippo, Efes! You have to open the config file manually and add them by "hand". Well that kinda stinks, don't you think? So here's my take on a convenient little class that allows you to either modify, add or delete any appSettings element, in either your Executable, Console or ASP.NET web application at runtime, on the fly. Bear in mind of course, that if you modify a web.config on a running ASP.NET app, the ASP.NET worker process will recycle. Users currently using your app aren't exactly guaranteed to have a fun experience when this happens...
Original Source: http://www.eggheadcafe.com/articles/20030907.aspBy Peter A. Bromberg, Ph.D.