About Stephen Jackson Expertise I can help with questions regarding VB.NET syntax and object references, with data interfaces and with the design and creation of robust, data aware object classes. I can also be very helpful with creating distributable applications and provide tricks and tips on .msi creation. I also have extensive experience in designing SQL Server Databases and interfacing them with VB.NET. I try to avoid web specific questions, as that is an area of expertise all its own.
Experience
Experience in the Area: I have been a programmer in Visual Basic since version 1.0 and have worked with VB.NET (which is infinitely more powerful than previous versions) since its initial release and SQL Server, both as a corporate IT professional and professional consultant. I first wrote Basic in 1976 on a TRS 80 and have worked in Visual Basic 1.0 and every subsequent release of Microsoft Visual Basic. I worked for over 7 years as a Senior Level Consultant in the area and currently hold a Project Manager position in IT.
Education and Credentials: MBA in Econometrics, 1983, University of Memphis.
BBA in Financial Management, 1982, Fogelman College of Business and Economics, University of Memphis. Microsoft Certified Professional
Areas of Special Expertise:
My specialty is the design of Object Oriented Solutions with robust, data aware object classes. I generally avoid the classic ‘Three Tier’ model as I find it redundant and cumbersome to maintain. I also specialize in the creation of ‘User Friendly’ User Interfaces which help lessen the need for user training and help prevent user error. I work best with Windows Forms based applications, and while I do work in C# as well, I prefer to limit my questions here to Windows Forms based applications created in Visual Basic.NET and SQL Server. I wil also address questions relating to the distribution and installation of Windows Forms based applications created in VB.NET.
Expert: Stephen Jackson Date: 5/1/2008 Subject: deleting
Question QUESTION: Hi Stephen,
I want to delete "on delete cascade" from my table.
I am using sql server 2005 express edition.
How to check all constraint for a table.
Have i to drop table or is there any command for dropping only "on delete cascade"
Thanks
ANSWER: Sukhvinder,
I do not use SQL Express Edition, but I am going to bet that this works the same as in SQL Server. Go to the table for which you wish to delete this rule (it will be the table with the related field - e.g. foreign key) and right click on the table and select 'Design Table'. On the toolbar find 'Table and Index Properties' and select it to open the Properties form for the Table. Click on the Relationships tab. There should be a relationship there describing the relationship between the Key and the Foreign Key.
You should see several options on this tab, including Cascade Update and Cascade Delete, which should be checked. Just uncheck it and save the table. This should remove the Cascade Delete feature for this relationship.
Let me know if this works for you, and please do not forget to leave me some feedback ... that is all we get in here ;c)
Thanks,
Stephen Jackson
---------- FOLLOW-UP ----------
QUESTION: Thanks Stephen,
U won.
Could please tell me how to delete the selected record from datagridview as i am using vb.net 2005 express edition.
I want to delete first from the child table which is in datagrid and then from parent table which is in textbox2.
i am providing the coding which is as following for delete button
Dim sqlconn As New SqlConnection("data source=TBPC25\SQLEXPRESS;Initial Catalog=RealEstate1;Integrated Security=True")
sqlconn.Open()
Dim dr As SqlDataReader
Dim cmd As SqlCommand
cmd = New SqlCommand("select * from legnresp where personid= ' " & TextBox2.Text & "' ", sqlconn)
dr = cmd.ExecuteReader
If dr.HasRows() = False Then
MsgBox("deleted from person table")
Do While dr.Read()
Loop
Else
MsgBox("can't delete as it has related record in datagrid")
End If
I don't how to write delete command in between do while loop so that matching record would be deleted.
Thanks
Sukhvinder
Answer Sukhvinder,
I would almost have to see your grid code to know how to handle this from the grid. If I may, I would really suggest that you use the key for the delete and execute a delete statement directly into SQL Server then refresh the grid. Scrolling like that leaves a lot of place for errors and will also perform much more slowly since you have to run a separate SQL transaction for each record, not to mention testing each one.
Thanks,
Stephen
PS: Thanks for the feedback! It is much appreciated! :c)