Solved

Address Book In VB

Posted on 2002-04-17
12
242 Views
Last Modified: 2010-05-02
Address Book In VB

Hi,

I want to create an Address Book in VB. The database can be created on SQL Server or Access.

The user computer may or may not have SQL Server or Microsoft Access.

1. How will my Address Book store data on the user's machine ??

2. Is there any other alternative of storing data ??

Thanks.
0
Comment
Question by:Sethi
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 3

Expert Comment

by:sridhar_PJ
ID: 6949684
0
 
LVL 18

Author Comment

by:Sethi
ID: 6949719
Can I run the application if the client machine doesn't have Access or SQL Server ?
0
 
LVL 5

Expert Comment

by:Bhaskar Ganapathe
ID: 6949769
Yes Sethi, you can run the application even if your machine doesn't have access or SQL Server.

If you use Access Database, then too u don't actually need MS Access in ur client machine.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:WizOfOz
ID: 6950023
just a lil tip.
You can use ADO to create recordset at run time that run in memory and don't use a database.
You can then persist the recordset by using the save method; using this method you can also save the data as xml...
0
 
LVL 18

Author Comment

by:Sethi
ID: 6950608
bhaspup, i am no able o run the application by using SQL Server, but it is working using Access...Any tips or sample code.
0
 
LVL 18

Author Comment

by:Sethi
ID: 6964519
I am still waiting for the way to run my application on the client side without SQL Server.
0
 

Expert Comment

by:WizOfOz
ID: 6964957
xcuse me, just a clarification...
It is a stand alone application running on a single machine?
If this is the case SQL Server isn't needed.
If you use the method stated in sridhar_PJ' comment or ADO recordset even Access isn't needed...

ie to create the recordset you do:
(taken directly from MSDN)


   Set rsCustomers = New ADODB.Recordset

   With rsCustomers
      ' Set CustomerID as the primary key.
      .Fields.Append "CustomerID", adChar, 5, adFldRowID
      .Fields.Append "CompanyName", adChar, 40, adFldUpdatable
      .Fields.Append "ContactName", adChar, 30, adFldUpdatable
      .Fields.Append "ContactTitle", adChar, 30, adFldUpdatable
      .Fields.Append "Address", adChar, 60, adFldUpdatable
      .Fields.Append "City", adChar, 15, adFldUpdatable
      .Fields.Append "Region", adChar, 15, adFldMayBeNull
      .Fields.Append "PostalCode", adChar, 10, adFldMayBeNull
      .Fields.Append "Country", adChar, 15, adFldUpdatable
      .Fields.Append "Phone", adChar, 24, adFldUpdatable
      .Fields.Append "Fax", adChar, 24, adFldMayBeNull
      ' Use Keyset cursor type to allow updating records.
      .CursorType = adOpenKeyset
      .LockType = adLockOptimistic
      .Open
   End With

then you have a open recordset not connected to a database...
the next step if you want to load/persist data in a text file is to load data from a text file:

(MSDN, same topic ->Creating a Data-Aware Class that Reads Records from a Delimited Text File)

   Dim fld As ADODB.Field
   Dim strRow As String
   Dim strField As String
   Dim intPos As Integer


   Open "Customers.txt" For Input As #1

   Do Until EOF(1)
      Line Input #1, strRow
      With rsCustomers
         .AddNew
         For Each fld In .Fields
            ' If a tab delimiter is found, field text is to the
            ' left of the delimiter.
            If InStr(strRow, Chr(9)) <> 0 Then
               ' Move position to tab delimiter.
               intPos = InStr(strRow, Chr(9))
               ' Assign field text to strField variable.
               strField = Left(strRow, intPos - 1)
            Else
               ' If a tab delimiter isn't found, field text is the
               ' last field in the row.
               strField = strRow
            End If

            ' Strip off quotation marks.
            If Left(strField, 1) = Chr(34) Then
               strField = Left(strField, Len(strField) - 1)
               strField = Right(strField, Len(strField) - 1)
            End If

            fld.Value = strField

            ' Strip off field value text from text row.
            strRow = Right(strRow, Len(strRow) - intPos)
            intPos = 0

         Next
         .Update
         .MoveFirst
      End With
   Loop
   Close

Now you have populated your recordset with the data you have persisted previously.

If you got MSDN I reccomend that you read the mentioned topic.

If you don't want a text file for your data (you know, users sooner or later will take a look in the text file...) you can:
persist data of from your recordset by using this code example taken from MSDN:

Dim rs as new Recordset
Dim rs2 as new Recordset
Dim c as new Connection
Dim s as new Stream

' Query the Titles table.
c.Open "provider=sqloledb;data source=mydb;initial catalog=pubs;user id=sa;password="
rs.cursorlocation = adUseClient
rs.Open "select * from titles", c, adOpenStatic

' Save to the file in the XML format. Note that if you don't specify
' adPersistXML, a binary format (ADTG) will be used by default.
rs.Save "titles.sav", adPersistXML

' Save the Recordset into the ADO Stream object.
rs.save s, adPersistXML
rs.Close
c.Close

set rs = nothing

' Reopen the file.
rs.Open "titles.sav",,,,adCmdFile
' Open the Stream back into a Recordset.
rs2.open s


Hope this will help

0
 
LVL 18

Author Comment

by:Sethi
ID: 6965210
This was a great help and infact a learning experience, but I have a database where I am maintaining relationships between tables, how would I maintain it here...It would be too tedious for me to maintain the application.

Cant we run an application without installing SQL Server on the client side ?

I am looking forward to your answer.
0
 
LVL 3

Expert Comment

by:sridhar_PJ
ID: 6965296
Hi Sethi,
Yes you can run your app and access Sql Server data from windows machine. The ODBC client for Sql server will be there by default in win98 and win2000.
To check goto control panel open Data Sources(ODBC) and click Add button. You will get list of installed drivers. Sql server will be in the list.
Add DSN and access your data.
Regards
Sridhar
0
 
LVL 18

Author Comment

by:Sethi
ID: 6966356
Sridhar my question is that I want to run an application created in VB/SQL Server, on a desktop that doesn't have SQL Server installed on it.

I am able to do it with Access, but not with SQL Server. Is it possible with SQL Server.

Even with DSN I have tried but it is not working.
0
 
LVL 3

Accepted Solution

by:
sridhar_PJ earned 50 total points
ID: 6967732
Sorry i can't get you. How can you access Sql server without installing a server. SQL server is not like MSAccess. It is true RDBMS. You can't access without SQL server installed on your machine.
i can give some other idea. Desktop version of SQL server is coming out. It is called MSDE. It is available in office 2000 CD. You can install MSSql Developer Edition on your Desktop and access that. You can control the database using MSACCESS. Please go through the documentaion with office CD.
Hope this help you
Regards
Sridhar
0
 
LVL 18

Author Comment

by:Sethi
ID: 6967753
This is what I was looking for. I am greatful to you for this answer.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question