This blog is about my history as a software engineer utilizing technologies C#, Java, React, JavaScript, .NET Core, SQL Server , Oracle, GIT, GitHub, Jira, Azure, AWS and HTML5. “I have not failed. I've just found 10,000 ways that won't work.” Thomas A. Edison. Please click on all my ADVERTISING links to help support this blog. Thank you.
Tuesday, March 26, 2013
Youtube good to know yellow line
When the red line reaches the yellow line, it means you can press the play button and continue your video without any pauses for buffering.
Friday, March 22, 2013
Tuesday, March 19, 2013
Using Statement to get 1 Scalar Value back from SQL
Public Function AddProductCategory( _ ByVal newName As String, ByVal connString As String) As Integer Dim newProdID As Int32 = 0 Dim sql As String = _ "INSERT INTO Production.ProductCategory (Name) VALUES (@Name); " _ & "SELECT CAST(scope_identity() AS int);" Using conn As New SqlConnection(connString) Dim cmd As New SqlCommand(sql, conn) cmd.Parameters.Add("@Name", SqlDbType.VarChar) cmd.Parameters("@Name").Value = newName Try conn.Open() newProdID = Convert.ToInt32(cmd.ExecuteScalar()) Catch ex As Exception Console.WriteLine(ex.Message) End Try End Using Return newProdID End Function
Monday, March 18, 2013
Working with Toolbox DataSources
Current contract I am working a lot with legacy code and find myself going over a pattern to ensure the additions I add remain in-line with the legacy code. Note the entire application is going to be re-written in about six months, so in order to save type by re-factoring I am simply following existing patterns.
Here is the key.
If a developer uses a Object or SQL Datasource you need to follow form the following:
1. ASP.NET (aka .aspx page control)
2. Next to the SQL or Object Data Source ensure the call to the SQL or OBJECT includes the data you need for step 1.
3. If you are performing OBJECT you need to expect the OBJECT that is being called to ensure the SQL or StoreProc is included for the data you need.
4. If SQL you need to ensure inline SQL is in place (Prevent Cross Site Scripting)
5. Then ensure the return to the control on the .aspx page.
6. Ensure all parameters in the INSERT, UPDATE, etc. Match the Controls #Bind("Naming_Structure") and to the object to the db, to keep things simple.
Follow the code from input to output....
Here is the key.
If a developer uses a Object or SQL Datasource you need to follow form the following:
1. ASP.NET (aka .aspx page control)
2. Next to the SQL or Object Data Source ensure the call to the SQL or OBJECT includes the data you need for step 1.
3. If you are performing OBJECT you need to expect the OBJECT that is being called to ensure the SQL or StoreProc is included for the data you need.
4. If SQL you need to ensure inline SQL is in place (Prevent Cross Site Scripting)
5. Then ensure the return to the control on the .aspx page.
6. Ensure all parameters in the INSERT, UPDATE, etc. Match the Controls #Bind("Naming_Structure") and to the object to the db, to keep things simple.
Follow the code from input to output....
Friday, March 15, 2013
SQLDataSource or ObjectDataSource
My experience with the DataSource Toolbox items (I try to stay away from them), but as a developer you always have to maintain another developer's code. Be sure to name your parameters and pass the same exact number of parameters to the calling INSERT, UPDATE, SELECT methods, it will save time and headaches.
You will have issues... More to come.
You will have issues... More to come.
Wednesday, March 13, 2013
SQL Server sp_who2 how to order
--sp_who2
DROP TABLE #sp_who2
CREATE TABLE #sp_who2
(SPID INT,
Status VARCHAR(1000) NULL,
Login SYSNAME NULL,
HostName SYSNAME NULL,
BlkBy SYSNAME NULL,
DBName SYSNAME NULL,
Command VARCHAR(1000) NULL,
CPUTime INT NULL,
DiskIO INT NULL,
LastBatch VARCHAR(1000) NULL,
ProgramName VARCHAR(1000) NULL,
SPID2 INT,
REQUESTID INT)
GO
INSERT INTO #sp_who2
EXEC sp_who2
SELECT * FROM #sp_who2 ORDER BY DiskIO DESC
ADO.NET Get Data to populate DataTable
#Region "Select Concern Status Values"
Public Function SelectProvConcernStatus() As DataTable
Dim dt As New DataTable
Try
Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("conn_string").ConnectionString)
conn.Open()
Using cmd As New SqlCommand("SELECT concern_status_id, concern_status FROM tbl_provider_concern_status", conn)
cmd.CommandType = CommandType.Text
Dim sda As SqlDataAdapter = New SqlDataAdapter(cmd)
sda.Fill(dt)
End Using
End Using
Return dt
Catch ex As Exception
Throw
End Try
End Function
#End Region
Tuesday, March 12, 2013
T-SQL Library - Check if Column Exists Alter Table
Composing T-SQL to run over and over to check into source control for column change....
IF NOT EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'tbl_Provider_Concerns'
AND COLUMN_NAME = 'concern_status_id')
BEGIN
ALTER TABLE tbl_Provider_Concerns
ADD concern_status_id INT
END
ALTER TABLE tbl_Provider_Concerns
ADD CONSTRAINT FK_Status
FOREIGN KEY(concern_status_id)
REFERENCES tbl_Provider_Concern_Status(concern_status_id)
Friday, March 08, 2013
TFS 2010 Build Automation - Issue with Solution with external project in another Source Control Folder
Backgroud on TFS Structure:
>***** Top level project (***** for security purpose)
--- Development
---XX
---XXirect* (This is what I am attempting to build, more details below)
--- QA
--- Root
Actual solution through Solution Explorer
XXirect-2.5.6.sln (Includes the following projects)
--XXirect (In the XXirect Folder)
--XX_CommonMethods (In the XX Folder aka referenced project)
Under the build definition if have the following:
Status
|
Source Control Folder
|
Build Agent Folder
|
Active
|
$/*****/Development/XX/XX_CommonMethods
|
$(SourceDir)\XX\XX_CommonMethods
|
Active
|
$/*****/Development/XXirect
|
$(SourceDir)
|
When I build I get the following error:
$/*****/Development/XXirect/XXirect-2.5.6.sln - 1 error(s), 103 warning(s), View Log File
C:\Builds\4\*****\XX_DEV - Draft\Sources\XXirect-2.5.6.sln.metaproj: The project file "C:\Builds\4\*****\XX_DEV - Draft\Sources\..\XX\XX_CommonMethods\XX_CommonMethods.csproj" was not found.
I have another build that I copied this template for that works fine. It actual builds to the build server (both containing the controller (m) and agent (007). Actually those are their names, just thought it was great how you explained that in the training.
The build actually builds then copies _Published folder to another server, which works fine. Again the issue I believe lies in the Mapping…
Any help would be great.
FIX
FIX
Try the following
Status
|
Source Control Folder
|
Build Agent Folder
|
Active
|
$/*****/Development/XX/XX_CommonMethods
|
$(SourceDir)\XX\XX_CommonMethods
|
Active
|
$/*****/Development/XXirect
|
$(SourceDir)\XXirect
|
Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies.
Blog: http://lajak.wordpress.com
Twitter: ahmedalasaad
Ahmed Al-Asaad - 5 STARS... You are the man. You suggested fixed the issue. Thank you so much.
I am writing the following for the MSDN community to help them as well.
Yesterday, I tried building individual projects instead of the .sln
In the Build Definition the two sections that are critical to this.
Workspace
tatus
|
Source Control Folder
|
Build Agent Folder
|
Active
|
$/*****/Development/XX/XX_CommonMethods
|
$(SourceDir)\XX\XX_CommonMethods
|
Active
|
$/*****/Development/XXirect/XXirect
(Had added to go directly after the .proj file instead of the .SLN
|
$(SourceDir) (NOTE THE XXIRECT WAS NOT ADDED)
|
Process
- Items to Build
- Here I switched to point directly to the XXirect *.*proj (Note - this was the attempt to fix it do not follow this)
- Also another gotcha is Configurations to Build -AnyCPU|Dev (Note the AnyCPU sometimes has a spaceAny CPU, note the space) which can causes an issue. GOTCHA look out for that.
Thankfully, I checked my email and Ahmed posted on MSDN the following change to the Workspace, which fixed the entire problem.
Status
|
Source Control Folder
|
Build Agent Folder
|
Active
|
$/*****/Development/XX/XX_CommonMethods
|
$(SourceDir)\XX\XX_CommonMethods
|
Active
|
$/*****/Development/XXirect
|
$(SourceDir)\XXirect
|
This also required swtiching the XXIRECT in the Source Control Folder to point to the *.sln and not the *.*proj file as well as switching back the Process to point to the *.sln successfully ran the build.
KUDOS KUDOS to Ahmed.
I searched all overt the Web for 8 hours looking and working on this yesterday. Ahmed and MSDN you really came through. Thanks also for David Star on Plural Sight for an awesome tutorial.
Tuesday, March 05, 2013
Programming as a career
Quoting my old mentor... You must be able to learn, unlearn and relearn to survive in the World of Software Development (Web Development) ever changing. Thank you Doug Cain.
Friday, March 01, 2013
Subscribe to:
Posts (Atom)