?
Solved

I need to update tables in SQL Server.

Posted on 1998-07-16
5
Medium Priority
?
174 Views
Last Modified: 2010-05-03
I need to update some tables in SQL Server from a VB application.
During the run time, these tables were not updatable for some reason.
I do not understand why they are not updatable.
This is the way I connect to SQL Server from a VB application as
the following:

    sConnect = "ODBC;DSN=ODBC_SQLServer;"
    sConnect = sConnect & "DATABASE=DatabaseName;"
    sConnect = sConnect & "UID=LoginID;" & "PWD="
    sConnect = sConnect & "Password;"
    Set WK = DBEngine.Workspaces(0)
    Set DB = WK.OpenDatabase("", False, False, sConnect)
    Set rs = DB.OpenRecordset("ChapterMemberRef", dbOpenDynaset, dbSeeChanges)

All tables in the SQL Server have permission to be updatable by
the login ID 'LoginID' and Password 'Password'.
The structure of 'ChapterMemberRef' has the following

MemberID       Integer
ChapterCode VarChar(5)

This table must allow to have duplicate MemberIDs and ChapterCodes.
There is no primary key in this table.
This table is a bridge table between a table named, Members which
has a primary key MemberID and another table named, Chapters which
has a primary key ChapterCode.

Does anybody have any suggestion?
Hope to hear your experienced answers from you soon. Thanks.

Hoosang
0
Comment
Question by:hoosang
  • 3
5 Comments
 

Author Comment

by:hoosang
ID: 1466036
Edited text of question
0
 
LVL 1

Expert Comment

by:brunchey
ID: 1466037
Could you send more code please.  Like all of it, with a comment on where you encountered the problem of not being able to update your code.
0
 

Author Comment

by:hoosang
ID: 1466038
After the code above, if I put a code as

rs.Add

Then VB application gave me an error

3027 This table is not updatable.
0
 
LVL 1

Accepted Solution

by:
DennisH earned 400 total points
ID: 1466039
The reason that the table is not updateable is because SQL Server requires a primary key in order to execute INSERT or SELECT statements through ODBC.  Add an AUTONUMBER field to this table and set the IDENTITY property of that field.  Save the Autonumber field value in your code and then use it for UPDATES.  You can ignore the autonumber field for INSERTS.
0
 

Author Comment

by:hoosang
ID: 1466040
I confirmed that your answer is correct. However, I like to know the reason behind it. I did not have any problem in MS Access.
Am I missing something in MS SQL Server? (Every time I create a table in MS SQL Server, do I need to set up at least one Primary Key in the table? Does this issue apply to other SQL servers (such as Oracle, Sybase, Informix and DB2)?)

Maybe I need to take SQL 101 class somewhere.


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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

850 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