Click here to Skip to main content
15,912,578 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: how to enlarge width data report ?? Pin
very_short_life9-Sep-06 4:28
very_short_life9-Sep-06 4:28 
QuestionVB6 - Inserting a data worksheet in a workbook. Pin
A Price7-Sep-06 17:00
A Price7-Sep-06 17:00 
QuestionHow to make glass effect image in .NET/WinXP Pin
re infecta7-Sep-06 10:44
re infecta7-Sep-06 10:44 
AnswerRe: How to make glass effect image in .NET/WinXP Pin
salysle7-Sep-06 13:21
salysle7-Sep-06 13:21 
GeneralRe: How to make glass effect image in .NET/WinXP Pin
re infecta7-Sep-06 20:55
re infecta7-Sep-06 20:55 
GeneralRe: How to make glass effect image in .NET/WinXP Pin
The ANZAC7-Sep-06 23:26
The ANZAC7-Sep-06 23:26 
AnswerRe: How to make glass effect image in .NET/WinXP Pin
hannesHTG8-Sep-06 3:33
hannesHTG8-Sep-06 3:33 
QuestionVB.NET not updating my primary keys Pin
MAJackson7-Sep-06 10:09
MAJackson7-Sep-06 10:09 
VB.NET against an Access database
This program is likely to be run very rarely, but for testing I'm running it several times a day. What I want to do is:
1. clear Table1
2. load Table1 with data

Since I'm doing this so often, I would rather generate my own Primary Key values and load them myself.

<br />
Dim drTable1 As DataRow = _<br />
  dsTable1.Tables("Table1").NewRow<br />
intKeyValue += 1     '----defined as Integer<br />
'-----RecKey is defined as the PrimaryKey, longinteger<br />
drTable1.Item("RecKey") = intKeyValue<br />
drTable1.Item("Data1") = "somestring"<br />
drTable1.Item("Data2") = "otherstring"<br />
dsTable1.Tables("Table1").Rows.Add(drTable1)<br />
daTable1.Update(dsTable1, "Table1")<br />


What's happening is that the first record is created ok, but with a keyvalue of zero. The next record gets rejected because it also contains a keyvalue of zero.

But the first DataRow that I've created contains a keyvalue of "1" and the second with a keyvalue of "2".

Question: why is the DataTable entry getting created with a keyvalue of zero, instead of the value I placed in the DataRow?

I can't find in the Knowledge Base where it addresses the question of where Access stores the most recent primary key value and how that is manipulated by the system and/or my program.

If I set the PrimaryKey to autonumber and let the system take care of things, it works just fine...but generates numbers that are getting very large. Sure, this is not a major problem; but I would really like to know why I can't create my own key values.

Meanwhile,
"How to use Microsoft Visual Basic .NET to connect to a Microsoft Access database and to retrieve data"
Article ID:821765 Last Review:September 13, 2005
Looks exactly like what I've been doing.

<br />
Dim i, sno As Integer<br />
Dim sname As String<br />
Dim rw As DataRow<br />
'Add a new row to the Student table.<br />
rw = DataSet11.Tables(0).NewRow<br />
sno = InputBox("Enter the Roll no of the Student:")<br />
sname = InputBox("Enter the Name of the Student:")<br />
rw.Item("SNo") = sno<br />
rw.Item("SName") = sname<br />
Try<br />
   DataSet11.Tables(0).Rows.Add(rw)<br />
   'Update the Student table in the testdb database.<br />
   i = OleDbDataAdapter1.Update(DataSet11)<br />
Catch ex As Exception<br />
   MessageBox.Show(ex.Message)<br />
End Try<br />
'Displays number of rows updated. <br />
MessageBox.Show("no of rows updated=" & i)<br />


I must be missing something obvious. Can anyone see what it is?

Michael AJ
AnswerRe: VB.NET not updating my primary keys Pin
MAJackson8-Sep-06 7:16
MAJackson8-Sep-06 7:16 
QuestionAppending Word Documents Pin
Wafdof7-Sep-06 9:13
Wafdof7-Sep-06 9:13 
Questioncalling a function in the code behind from java script Pin
ONeil Tomlinson7-Sep-06 7:18
ONeil Tomlinson7-Sep-06 7:18 
AnswerRe: calling a function in the code behind from java script Pin
Guffa7-Sep-06 8:22
Guffa7-Sep-06 8:22 
Questionhow to export / save wave file from Resource as wave file Pin
elsahaba7-Sep-06 6:47
elsahaba7-Sep-06 6:47 
QuestionTreeview question Pin
KreativeKai7-Sep-06 6:32
professionalKreativeKai7-Sep-06 6:32 
AnswerRe: Treeview question Pin
KreativeKai7-Sep-06 9:20
professionalKreativeKai7-Sep-06 9:20 
AnswerRe: Treeview question Pin
salysle7-Sep-06 13:15
salysle7-Sep-06 13:15 
Questioneditable datagrid column Pin
vidhu raj7-Sep-06 5:03
vidhu raj7-Sep-06 5:03 
AnswerRe: editable datagrid column Pin
KreativeKai7-Sep-06 8:30
professionalKreativeKai7-Sep-06 8:30 
Questionprocedure working fine with oracle is not working when i call from vb Pin
Mohamed nishar7-Sep-06 4:48
Mohamed nishar7-Sep-06 4:48 
QuestionFunction to reverse a number Pin
dcomf7-Sep-06 4:24
dcomf7-Sep-06 4:24 
AnswerRe: Function to reverse a number Pin
aniskhan7-Sep-06 5:04
aniskhan7-Sep-06 5:04 
AnswerRe: Function to reverse a number Pin
aniskhan7-Sep-06 5:35
aniskhan7-Sep-06 5:35 
AnswerRe: Function to reverse a number Pin
Guffa7-Sep-06 8:28
Guffa7-Sep-06 8:28 
QuestionHow to update a table Pin
cstrader2327-Sep-06 2:17
cstrader2327-Sep-06 2:17 
AnswerRe: How to update a table Pin
Nikhil Bandekar7-Sep-06 23:30
Nikhil Bandekar7-Sep-06 23:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.