Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please point me in the right direction 1

Status
Not open for further replies.

Greyfleck

IS-IT--Management
Jun 2, 2008
61
GB
Having spent the last two years writing with Access (2003/2007) and finding the deployment (security messages et al)just a pain I decided to change tack and try VB (after all VBA to VB should be a doddle right>?)

I am finding it really hard to get into the VB mindset and am looking for a good book to get me on the right track.

What I am really after is a book that deals with the simple things in life - not the squillion nice to haves in VB but just something I can relate my Access experience to so I can re-develop my application without too much stress!!

For example, in Access I link to my backend at the start of my application (and relink of already there) and that is all I need to do.

Can I do this in VB? I have seen many examples of connecting each time a form is loaded.

Finally I have yet to see sub-forms in VB - Do they exist.

I guess that I have asked many questions but hope that someone can give me simple answers.

I am using visual studio 2008 professional with SQL Server 3.5 compact as a back end if that helps.

Many Thanks


Jon



 
Jon,
First of all, welcome to VB.Net programming. There are some things to know which make developing in VB different than Access VBA.

Firstly, VB.Net is a general-purpose programming language. You can write database applications, program TCP/IP network programs, and even write games. So one thing you will notice is that many of the things you found in Access are now more generalized in VB. Taking your subform example, Access has a strong link between a "form" and data. Subforms in Access are usually meant to show records related to the selected record in the main form. However, in VB a form is just a special type of class which doesn't require data access components and many forms don't have anything to do with data. So in answer to your subform question--yes you can have "sub forms," or their equivalent in VB.Net. You can embed one form within another, you can embed a panel in a form, or you can even just set up your controls and your DataSets so that related records are displayed in controls within the same form.

Secondly, modern VB and VBA are extremely different. VBA syntax is simliar to Visual Basic 6 syntax. In 2002, VB.Net was released and the language is very different from old style VB. Visual Basic is now a true object oriented language just like C# and Java.

For example, in Access I link to my backend at the start of my application (and relink of already there) and that is all I need to do.

Can I do this in VB? I have seen many examples of connecting each time a form is loaded.

I'm not sure what you mean there. Can you elaborate more?

Another thing to keep in mind would be your database backend. SQL Compact is extremely limited, and just keep in mind that it does not support many SQL Server/SQL Express queries which developers take for granted.

As far as a book recommendation is concerned, I haven't purchased one in several years. However, I would recommend finding a good book for beginning programming which uses VB 2008 for the examples. I think it would be a better approach to learn 3GL programming and the .Net framework first rather than trying to dive directly into the data access libraries of .Net.
 
To elaborate on the Quote, it is all about connections.

In access I link to the backend db once at the start of the process. After that my tables are available throughout the instance of Access.

In VB I have seen the connection string
Code:
Dim con As New SqlConnection("Initial Catalog=stock;Data source=.;Integrated security =true")
Dim da1 As New SqlDataAdapter("select * from sto", con)
Dim ds1 As New DataSet
DataGrid2.Refresda1.Fill(ds1)
DataGrid2.Refresh()
DataGrid2.DataSource = ds1.Tables(0)

appear on form 1 of 10 (in an application)

and

Code:
Dim con As New SqlConnection("Initial Catalog=stock;Data source=.;Integrated security =true")
Dim cm As New SqlCommand
cm.Connection = con
cm.Connection.Open()

appears on form 3

So it appears that connections are made for each form/process.

Perhaps vb & .net are not my solution ... I may have to look elsewhere for now..

Thanks for you time anyway

Jon


 
That's the thing -- there is no single way to do things in VB/.Net. The code you saw reflected the developer's preference for the specific application. He or she could have added a class module and put the connection there once. They could have created a data access class with a single shared connection. They could have instanced the connection in one class (or form) and passed it through to others. I wouldn't discount VB/.Net just yet. But, again, VB and Access aren't interchangeable tools.

Access is a lightweight database system which allows you to add your own code and own user interface forms. VB/.Net is a language and framework for creating all sorts of applications of which database applications are one of many. VB will be more powerful, however, it requires more time to accomplish some of the more mundane tasks. You have to choose and setup up your deployment scenario. There's no simple, built-in way to make a form change from a DataGrid to a completed form with textboxes for all of your controls (that I know of).
 
HI RiverGuy..

I am also pretty new to vb.net...
I was wondering how can we have the connection in one place and use it in all the forms..
 
njahnavi,
See this thread. Someone asked the same question.
thread796-1532328
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top