Solved

Address Book In VB

Posted on 2002-04-17
12
235 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 78
Cannot Load VB6 on Windows 10. Installed OK but error on opening existing project. 7 76
TT Auto Dashboard 13 83
VB6 ListBox Question 4 32
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now