Monday, 18 June 2018

Finding the perfect workplace

As a contractor, I have less criteria for perfect workplaces. Recently I only check few things like

  • Flexible working hours
  • Dress code
  • Development hardware and software
  • Money (obviously)
  • Projects and nature of business
Sometimes I got job offers for permanent roles. I'm definitely more picky when it comes to permanent. I had few bad experiences and each one added up an item or two to my criteria list. 

  • Opening for new technologies
  • Training opportunities
  • Infrasturcture
  • Level of contribution to work 
  • Colleagues
  • Trust 
  • In-company peace
I know, some of them cannot be measured before you start but if 2-3 of them fails I start feeling uncomfortable and adding one more gives me a signal to leave. 


Friday, 23 March 2018

Starting a new project

Hi there,

I'm going to start a new project and I'll try to write a full diar

Friday, 28 March 2014

SQL SERVER – FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user


This error is quite common and I have received it few times while I was working on a recent consultation project.
Cannot open database requested by the login. The login failed.
Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’.
This error occurs when you have configured your application with IIS, and IIS goes to SQL Server and tries to login with credentials that do not have proper permissions. This error can also occur when replication or mirroring is set up.
If you search online, there are many different solutions provided to solve this error, and many of these solutions work fine. However, I will be going over a solution that works always and is very simple.
Fix/Workaround/Solution:
Go to SQL Server >> Security >> Logins and right click on NT AUTHORITY\NETWORK SERVICE and select Properties
In newly opened screen of Login Properties, go to the “User Mapping” tab. Then, on the “User Mapping” tab, select the desired database – especially the database for which this error message is displayed. On the lower screen, check the role db_owner. Click OK.
In almost all such cases, this should fix your problem

SQL SERVER – Fix: Error: 15138 – The database principal owns a schema in the database, and cannot be dropped




Last day I had excellent fun asking puzzle on SQL Server Login SQL SERVER – Merry Christmas and Happy Holidays – Database Properties – Number of Users. One of the user sent me email asking urgent question about how to resolve following error. Reader was trying to remove the login from database but every single time he was getting error and was not able to remove the user.
The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138)
As per him it was very urgent and he was not able to solve the same. I totally understand his situation and here is the quick workaround to the issue. The reason for error is quite clear from the error message as there were schema associated with the user and that needs to be transferred to another user.
Workaround / Resolution / Fix:
Let us assume that user was trying to delete user which is named as ‘pinaladmin’ and it exists in the database ‘AdventureWorks’.
Now run following script with the context of the database where user belongs.
USE AdventureWorks;SELECT s.nameFROM sys.schemas sWHERE s.principal_id USER_ID('pinaladmin');
In my query I get following two schema as a result.
Now let us run following query where I will take my schema and and alter authorization on schema. In our case we have two schema so we will execute it two times.
ALTER AUTHORIZATION ON SCHEMA::db_denydatareader TO dbo;ALTER AUTHORIZATION ON SCHEMA::db_denydatawriter TO dbo;
Now if you drop the database owner it will not throw any error.
Here is generic script for resolving the error:
SELECT s.nameFROM sys.schemas sWHERE s.principal_id USER_ID('YourUserID');
Now replace the result name in following script:
ALTER AUTHORIZATION ON SCHEMA::YourSchemaName TO dbo;

Thursday, 9 January 2014

preventing double click

I put this somewhere in between body tags in an ASP.NET page and works


<!-- PREVENTING DOUBLE CLICK -->
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
 function BeginRequestHandler(sender, args) { var oControl = args.get_postBackElement(); oControl.disabled = true; }
</script>

Monday, 7 October 2013

Method Dispatch in Ruby (include, extend, super and prepend)


Include 

Include  is for adding methods to an instance of a class

Extend

Extend is for adding class methods. (like self. )

module Foo
  def foo
    puts 'heyyyyoooo!'
  end
end

class Bar
  include Foo
end

Bar.new.foo # heyyyyoooo!
Bar.foo # NoMethodError: undefined method ‘foo’ for Bar:Class

class Baz
  extend Foo
end

Baz.foo # heyyyyoooo!
Baz.new.foo # NoMethodError: undefined method ‘foo’ for #<Baz:0x1e708>
As you can see, include makes the foo method available to an instance of a class and extend makes the foo method available to the class itself.


References :
http://blog.jcoglan.com/2013/05/08/how-ruby-method-dispatch-works/
http://www.railstips.org/blog/archives/2009/05/15/include-vs-extend-in-ruby/

Monday, 2 September 2013

AJAX problem

http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx  

Just in case of page removal here is the page content 

Gotcha: Don't use <xhtmlConformance mode="Legacy"/> with ASP.NET AJAX

Recently I've helped a few developers who have been having some weird JavaScript issues (both when using ASP.NET AJAX and with some other custom JavaScript routines they were using).  The culprit was that they had automatically migrated a VS 2003 Web Project to VS 2005, and still had the <xhtmlConformance mode="Legacy"/> switch configured within their web.config file. 
If you are writing custom client-side JavaScript in your web application and/or are going to be using AJAX, please read-on to learn how to avoid a common gotcha (note: for a list of other tips, tricks, recipes and gotchas I've previously posted, please check out this page here).
Symptom:
You see strange behavior when adding new client-side JavaScript to a project that was previously upgraded (successfully) from VS 2003 to VS 2005.  When using ASP.NET AJAX UpdatePanel controls, this strange behavior can sometimes include cases where the page does a full-page postback instead of just incrementally updating pieces of a page. 
When you open up your web.config file, you also see a <xhtmlConformance/> element within it like so:
<configuration>

    
<system.web>
        
<xhtmlConformance mode="Legacy" />
    </
system.web>
</configuration>
Background:
ASP.NET 1.0 and 1.1 didn't emit XHTML compliant markup from many of its server controls.  ASP.NET 2.0 changed this and by default emits XHTML compliant markup from all controls (note: you can learn more about ASP.NET 2.0's standards compliance from this excellent MSDN article).
One of the things we noticed in the early ASP.NET 2.0 betas, though, was that when upgrading customer applications a lot of the applications had assumptions that the page output was not XHTML compliant.  By changing our default output of the server controls to be XHTML, it sometimes modified the visual rendering of a page.  For backwards compatibility purposes we added the <xhtmlConformance> switch above that allows developers to render controls in "Legacy" mode (non-XHTML markup the same as ASP.NET 1.1) as well as Transitional mode (XHTML Transitional) as well as Strict mode (XHTML Strict). 
By default when you use the VS 2003->VS 2005 Web Project Migration wizard (for both web sites and web application projects), your web.config file will have the legacy switch added.
Solution:
Unless you know of known issues that your site has when running in XHTML mode (and which you don't have time yet to fix), I'd always recommend removing the <xhtmlConformance> section from your web.config file (or you can explicitly set it to "Transitional" or "Strict"). 
This will make your HTML output standards compliant.  Among other things, this will cause the HTML from your server controls to be "well formed" - meaning open and close tag elements always match.  This is particularly important when you are using AJAX techniques to dynamically replace the contents of certain HTML elements on your page (otherwise the client-side JavaScript sometimes gets confused about container elements and can lead to errors).  It will also ensure that ASP.NET AJAX works fine with your site.
Hope this helps,
Scott

Friday, 30 August 2013

Validation of viewstate MAC failed problem

in Web Config 
<machineKey decryptionKey="A4B12CCDD50E95F8GB9GFH6JKAT4Y0U0I2OF2DF2AAFE5AB46189C,IsolateApps" validation="AES" validationKey="480CDF2AS9S9AS5CFDGF0GHFH9JJH4KHKAKLJ2L9F3SAS82A6C16911A29EF48903783F94529C21570AACB72766FB38CD4CE7B85B0ACE3149DC5FC1CCF1AA1CECE3579659996593B06,IsolateApps"/>
Or in aspx page 
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin/Site1.Master"  EnableViewStateMac="false" CodeBehind="MenuStructure.aspx.vb" Inherits="LogicTextile.MenuStructure" %>

Wednesday, 28 August 2013

Space between RadioButtonGroup in ASP.NET

in code behind :

            rbMode.Items(0).Attributes.CssStyle.Add("margin-right", "15px")
            rbMode.Items(1).Attributes.CssStyle.Add("margin-right", "15px")

Tuesday, 6 August 2013

SQL SERVER – Query to Find ByteSize of All the Tables in Database

SELECT CASE WHEN (GROUPING(sob.name)=1THEN 'All_Tables'
   
ELSE ISNULL(sob.name'unknown'END AS Table_name,
   
SUM(sys.lengthAS Byte_LengthFROM sysobjects sobsyscolumns sysWHERE sob.xtype='u' AND sys.id=sob.idGROUP BY sob.nameWITH CUBE

Friday, 2 August 2013

using radio in ASP.NET treeview instead of checkboxes

<script type="text/javascript">
    function MakeRadio() {
        var tv = document.getElementById("<%= TV.ClientID %>");
        var chkArray = tv.getElementsByTagName("input");

        for (i = 0; i <= chkArray.length - 1; i++) {
            if (chkArray[i].type == 'checkbox') {
                chkArray[i].type = 'radio';
            }
        }
    }

    window.onload = MakeRadio;

    function OnTreeClick(evt) {
        var src = window.event != window.undefined ? window.event.srcElement : evt.target;
        var isChkBoxClick = (src.tagName.toLowerCase() == "input" && src.type == "radio");
        if (isChkBoxClick) {
            SelectOne(src.id);
        }
    }

    function SelectOne(objId) {
        var tv = document.getElementById("<%= TV.ClientID %>");
        var chkArray = tv.getElementsByTagName("input");

        for (i = 0; i <= chkArray.length - 1; i++) {
            if (chkArray[i].type == 'radio') {
                if (chkArray[i].id != objId) {
                    chkArray[i].checked = false;
                }
            }
        }
    }
</script>

<asp:TreeView ID="TV" runat="server"></asp:TreeView>

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                TV.Attributes.Add("onclick", "OnTreeClick(event)")
End Sub


Tuesday, 14 May 2013

Using Git Hub in Visual Studio

This subject is definetely pain in the ass.
The best documentation I found in the net is http://codeasp.net/blogs/vivek_iit/microsoft-net/1881/how-to-use-github-with-visual-studio

Following these steps can sort this problem out. I only stucked in step 10 and our sysadmin helped me in this step. (SSH key )


Tuesday, 30 April 2013

OOP or OOPS

Hi everybody,

I'm dealing with some strange codes developed by some other developers nowadays. In first sight they seem like Object Oriented. Let's have a look.

Codes are in ASP.NET using VB. Developer wrote these codes like that.
There are aspx UI pages and separete code pages which they are as they should be.
and there are module pages for each pair.
but WHY ?

First reasonable explanation came to my mind was reusability. But no. 95% of these modules used only once.  So why should we travel from function to function for a simple data save ? Is that what he understands about OOP ?

Please guys, codes must be in balance. Balance of performance, readability, standards and reusability.
we don't develope anything for ourselves. Someday in some point some other developer will continue the job you left. Think about him and leave clean, wise, readable codes. 

Thursday, 6 September 2012

Windows Task Scheduler Result Codes


SCHED_S_TASK_READY
0x00041300
The task is ready to run at its next scheduled time.
SCHED_S_TASK_RUNNING
0x00041301
The task is currently running.
SCHED_S_TASK_DISABLED
0x00041302
The task will not run at the scheduled times because it has been disabled.
SCHED_S_TASK_HAS_NOT_RUN
0x00041303
The task has not yet run.
SCHED_S_TASK_NO_MORE_RUNS
0x00041304
There are no more runs scheduled for this task.
SCHED_S_TASK_NOT_SCHEDULED
0x00041305
One or more of the properties that are needed to run this task on a schedule have not been set.
SCHED_S_TASK_TERMINATED
0x00041306
The last run of the task was terminated by the user.
SCHED_S_TASK_NO_VALID_TRIGGERS
0x00041307
Either the task has no triggers or the existing triggers are disabled or not set.
SCHED_S_EVENT_TRIGGER
0x00041308
Event triggers do not have set run times.
SCHED_E_TRIGGER_NOT_FOUND
0x80041309
A task's trigger is not found.
SCHED_E_TASK_NOT_READY
0x8004130A
One or more of the properties required to run this task have not been set.
SCHED_E_TASK_NOT_RUNNING
0x8004130B
There is no running instance of the task.
SCHED_E_SERVICE_NOT_INSTALLED
0x8004130C
The Task Scheduler service is not installed on this computer.
SCHED_E_CANNOT_OPEN_TASK
0x8004130D
The task object could not be opened.
SCHED_E_INVALID_TASK
0x8004130E
The object is either an invalid task object or is not a task object.
SCHED_E_ACCOUNT_INFORMATION_NOT_SET
0x8004130F
No account information could be found in the Task Scheduler security database for the task indicated.
SCHED_E_ACCOUNT_NAME_NOT_FOUND
0x80041310
Unable to establish existence of the account specified.
SCHED_E_ACCOUNT_DBASE_CORRUPT
0x80041311
Corruption was detected in the Task Scheduler security database; the database has been reset.
SCHED_E_NO_SECURITY_SERVICES
0x80041312
Task Scheduler security services are available only on Windows NT.
SCHED_E_UNKNOWN_OBJECT_VERSION
0x80041313
The task object version is either unsupported or invalid.
SCHED_E_UNSUPPORTED_ACCOUNT_OPTION
0x80041314
The task has been configured with an unsupported combination of account settings and run time options.
SCHED_E_SERVICE_NOT_RUNNING
0x80041315
The Task Scheduler Service is not running.
SCHED_E_UNEXPECTEDNODE
0x80041316
The task XML contains an unexpected node.
SCHED_E_NAMESPACE
0x80041317
The task XML contains an element or attribute from an unexpected namespace.
SCHED_E_INVALIDVALUE
0x80041318
The task XML contains a value which is incorrectly formatted or out of range.
SCHED_E_MISSINGNODE
0x80041319
The task XML is missing a required element or attribute.
SCHED_E_MALFORMEDXML
0x8004131A
The task XML is malformed.
SCHED_S_SOME_TRIGGERS_FAILED
0x0004131B
The task is registered, but not all specified triggers will start the task.
SCHED_S_BATCH_LOGON_PROBLEM
0x0004131C
The task is registered, but may fail to start. Batch logon privilege needs to be enabled for the task principal.
SCHED_E_TOO_MANY_NODES
0x8004131D
The task XML contains too many nodes of the same type.
SCHED_E_PAST_END_BOUNDARY
0x8004131E
The task cannot be started after the trigger end boundary.
SCHED_E_ALREADY_RUNNING
0x8004131F
An instance of this task is already running.
SCHED_E_USER_NOT_LOGGED_ON
0x80041320
The task will not run because the user is not logged on.
SCHED_E_INVALID_TASK_HASH
0x80041321
The task image is corrupt or has been tampered with.
SCHED_E_SERVICE_NOT_AVAILABLE
0x80041322
The Task Scheduler service is not available.
SCHED_E_SERVICE_TOO_BUSY
0x80041323
The Task Scheduler service is too busy to handle your request. Please try again later.
SCHED_E_TASK_ATTEMPTED
0x80041324
The Task Scheduler service attempted to run the task, but the task did not run due to one of the constraints in the task definition.
SCHED_S_TASK_QUEUED
0x00041325
The Task Scheduler service has asked the task to run.
SCHED_E_TASK_DISABLED
0x80041326
The task is disabled.
SCHED_E_TASK_NOT_V1_COMPAT
0x80041327
The task has properties that are not compatible with earlier versions of Windows.
SCHED_E_START_ON_DEMAND
0x80041328
The task settings do not allow the task to start on demand.

Tuesday, 12 June 2012

Friday, 8 June 2012

SQL Transaction usage in Vb.NET

Dim sqlConn As New SqlConnection(Current.Application.Get("dbstring"))
........
sqlConn.Open()
Dim sqlTrans As SqlTransaction = sqlConn.BeginTransaction()

saveSupplierRecord(sqlTrans, ......
 sqlTrans.Commit() || sqlTrans.Rollback()
-------------------------------------------------------
Function InsertTransaction(ByRef sqlTrans As SqlTransaction .....
  Dim sqlConn As SqlConnection
  sqlConn = sqlTrans.Connection

.......
End Function

Wednesday, 25 April 2012

ASP.NET with some AJAX

Here is the AjaxcontrolToolkit Link
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/Default.aspx
This toolkit is an open source project simply does ajax jobs relatively easier way.

Some JQuery and Javascript Links
http://www.dhtmlgoodies.com

Wednesday, 18 April 2012

ASP.NET Template Field Command Triggering

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                     OnRowCommand="GridView1_RowCommand">
                        <Columns>
                            <asp:BoundField DataField="ID" HeaderText="ID" Visible="False" />
                            <asp:BoundField HeaderText="Field Name" DataField="CurrencyName" >
                            </asp:BoundField>
                                                   
                             <asp:TemplateField ShowHeader="False">
                                 <ItemTemplate>
                                     <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="false" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ID")%>'
                                         CommandName="ItemDelete" ImageUrl="~/Admin/Img/Delete.png" Text="Button" />
                                 </ItemTemplate>
                                 <ItemStyle Width="18px" />
                            </asp:TemplateField>
                            
                        </Columns>
                  </asp:GridView>


    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
        Dim MyPool As New LogicPool.DB("Conn")
        If (e.CommandName = "ItemDelete") Then

            Dim index As Integer = Convert.ToInt32(e.CommandArgument)
            MyPool.SQLRun("DELETE FROM AppCurrencyRules WHERE ID = " & index)
            FillGrid()
        End If
    End Sub

Tuesday, 3 April 2012

Data Types (why?)

Finally in my 19th year in my professional carreer second time I saw another crazy programmer's code.
In the evaluation of computers and development techniques some developers resist to accept new techniques. about 10 years ago I had a collegue. He attented all those system analysis meetings, we built up data structure, process structure, road map together. We decided to use Informix SQL in those time as database. He had a strong background in DOS - Cobol systems. I think it was his first time to use a proper database. He used his own binary files as database until that time.

Then we began development. According to plan I was developing web end, he was developing windows end and we were good until the day we had to integrate both parts. I connected his database and surprised a bit. The data structure was OK but in every table there was one additional field which was binary. I didn't get it and asked him what it was. His answer was killing. He said "after he populates data from the screen he converted all of them to binary and write that field" I asked why didn't he use the all structure? He said he is faster with his way.

Nearly 1 year of analysis and data structure work has gone to rubbish bin. He suggest me to develop an interface to read his data.

In these 10 years it was my stragest memory. Until 5 minutes ago...

While I was examining the most complex code I ever seen I somehow couldn't find where is the problem. I can't debug it because of the arthitecture. I tried to follow the code line by line. In some point I saw there is an image field in database which is possible. There are some images and it can be normal. But the image field there bothered me and tried to find when it's used.

Yes. The same thing happened. Previous developer populated some fields and convert them into binary and wrote that field.

I can't believe this. Guys where did you see this technique ? First guy was Turkish  lives in Istanbul in all his life and second one is British living in UK.

Is it a kind of joke ?

Tuesday, 6 March 2012

Text to Object or dynamically creating menu

The most important function is

    Public Function DynamicallyLoadedObject(ByVal objectName As String, Optional ByVal args() As Object = Nothing) As Object
        Dim returnObj As Object = Nothing
        Dim type As Type = Assembly.GetExecutingAssembly().GetType(Application.ProductName & "." & objectName)

        If Not type Is Nothing Then
            returnObj = Activator.CreateInstance(type, args)
        End If

        Return returnObj
    End Function


This function converts form names from text format to form objects. Here is my piece of code generating menu and assigning events to menu click.

Private Sub menuClickedEvent(ByVal sender As Object, ByVal e As EventArgs)
                 Dim ChildForm As New System.Windows.Forms.Form
                ChildForm = DynamicallyLoadedObject(newItem.Tag) 
                ChildForm.Show()

End Sub


Public Sub CreateMenu(ByVal MyMenuStrip As MenuStrip, Optional ByVal MyToolbar As ToolStrip = Nothing)
        Dim MyDB As New LogicPool.DB(_MySettings._DataConnection)
        Dim MYDS As New Data.DataSet
       
        MyDB.SQLReturnDT(MYDS, "Menu", "SELECT * FROM SysMenu M, SysUserRight H WHERE H.SysMenuID = M.ID AND H.SysUserID = " & _User._ID & " ORDER BY SortOrder")
    
        MyMenuStrip.Items.Clear()
        MenuPrepare(MYDS.Tables("Menu"), MyMenuStrip, MyToolbar)
    End Sub





Private Sub MenuPrepare(ByVal db As DataTable, ByVal MS As MenuStrip, Optional ByVal tb1 As System.Windows.Forms.ToolStrip = Nothing, Optional ByVal ref As Integer = 0, Optional ByVal ItemKey As Object = Nothing)
        Dim z As Integer
        Dim MyDB As New LogicPool.DB(_MySettings._DataConnection)
        For z = 0 To db.Rows.Count - 1
            ' 1. Seviye
            If ref = 0 Then
                If CInt(db.Rows(z).Item("RefID")) = 0 Then
                    Dim newItem As New System.Windows.Forms.ToolStripMenuItem
                    If db.Rows(z).Item("FormName").ToString.Trim.Length > 0 Then
                        newItem = MS.Items.Add(db.Rows(z).Item("MenuName"), Nothing, New System.EventHandler(AddressOf menuClickedEvent))
                        newItem.Tag = db.Rows(z).Item("FormName")
                    Else
                        newItem = MS.Items.Add(db.Rows(z).Item("MenuName"), Nothing)
                    End If
                    If db.Rows(z).Item("ImageName").ToString.Trim.Length > 0 Then
                        Dim Newimg As System.Drawing.Image
                        Newimg = FrmImages.imgMenu.Images(db.Rows(z).Item("ImageName").ToString)
                        newItem.Image = Newimg
                    End If

                    newItem.Name = "Mn" & db.Rows(z).Item("ID")
                    MenuPrepare(db, MS, tb1, db.Rows(z).Item("ID"), newItem)


                End If
                ' Diğer Seviyeler
            Else
                If CInt(db.Rows(z).Item("RefID")) = ref Then
                    Dim newItem As New System.Windows.Forms.ToolStripMenuItem
                    Dim OldItem As System.Windows.Forms.ToolStripMenuItem
                    OldItem = ItemKey

                    newItem = OldItem.DropDown.Items.Add(db.Rows(z).Item("MenuName"), Nothing, New System.EventHandler(AddressOf menuClickedEvent))

                    If db.Rows(z).Item("FormName").ToString.Trim.Length > 0 Then
                        newItem.Tag = db.Rows(z).Item("FormName")
                    End If


                    If db.Rows(z).Item("ImageName").ToString.Trim.Length > 0 Then
                        Dim Newimg As System.Drawing.Image
                        Newimg = FrmImages.imgMenu.Images(db.Rows(z).Item("ImageName").ToString)
                        newItem.Image = Newimg
                        If Not tb1 Is Nothing Then
                            If db.Rows(z).Item("Toolbar") = 1 Then
                                Dim TB As System.Windows.Forms.ToolStripItem
                                TB = tb1.Items.Add(db.Rows(z).Item("MenuName"), Newimg, New System.EventHandler(AddressOf ToolbarClickEvent))
                                TB.Tag = db.Rows(z).Item("FormName")
                                If MyDB.ParameterGet("ToolbarText") = 0 Then
                                    TB.DisplayStyle = ToolStripItemDisplayStyle.Image
                                Else
                                    TB.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
                                End If
                                TB.ToolTipText = db.Rows(z).Item("MenuName")
                                tb1.Items.Add(New System.Windows.Forms.ToolStripSeparator)
                            End If
                        End If
                    End If

                    newItem.Name = "Mn" & db.Rows(z).Item("ID")
                    MenuPrepare(db, MS, tb1, db.Rows(z).Item("ID"), newItem)
                End If
            End If
        Next
    End Sub