Click here to Skip to main content
15,923,142 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralDataGrid Rows Pin
8-Jan-05 17:04
suss8-Jan-05 17:04 
GeneralRe: DataGrid Rows Pin
Palestine_Guy8-Jan-05 20:47
Palestine_Guy8-Jan-05 20:47 
GeneralRe: DataGrid Rows Pin
Makniteasy8-Jan-05 21:13
Makniteasy8-Jan-05 21:13 
GeneralRe: DataGrid Rows Pin
Palestine_Guy9-Jan-05 22:19
Palestine_Guy9-Jan-05 22:19 
QuestionFoxpro Data with VB6? Pin
paykani8-Jan-05 16:56
paykani8-Jan-05 16:56 
AnswerRe: Foxpro Data with VB6? Pin
Robert Rohde9-Jan-05 6:17
Robert Rohde9-Jan-05 6:17 
GeneralDatabase question Pin
sangsram8-Jan-05 14:17
sangsram8-Jan-05 14:17 
GeneralInserting rows from data grid Pin
Anonymous8-Jan-05 10:49
Anonymous8-Jan-05 10:49 
Hi all,

I would like to insert all records found in my datagrid into my table. The following code works but then there are limitation.

I am using a For next loop to insert the rows from teh grid.
The problem is if there less than 21 records then VB throws this error:
No row at index.

Can some one help mewith this.

Tnx

Here is the code for Button_click
Dim da As New OleDbDataAdapter()
Dim da1 As New OleDbDataAdapter()
da.SelectCommand = New OleDbCommand()
da.SelectCommand.Connection = conn
da1.SelectCommand = New OleDbCommand()
da1.SelectCommand.Connection = conn
If conn.State <> ConnectionState.Open Then conn.Open()

da.SelectCommand.CommandText = "Delete from Test where rectp = 'SH' and pkey = '001'"
da.SelectCommand.CommandType = CommandType.Text
da.SelectCommand.ExecuteNonQuery()


Dim Icount As Integer
For Icount = 0 To 20
If DBgrid2.Item(Icount, 0) <> "null" And DBgrid2.Item(Icount, 1) <> "null" And DBgrid2.Item(Icount, 2) <> "null" And DBgrid2.Item(Icount, 3) <> "null" Then
da1.SelectCommand.CommandText = "insert into Test values('SH','" & Format(vBcust, "0000000") + Format(vSeqno, "000") & "'," & Icount & ",'" & DBgrid2.Item(Icount, 0) & "','" & DBgrid2.Item(Icount, 2) & "','" & DBgrid2.Item(Icount, 3) & "')"
da1.SelectCommand.CommandType = CommandType.Text
da1.SelectCommand.ExecuteNonQuery()
End If
Next
GeneralRe: Inserting rows from data grid Pin
Anonymous9-Jan-05 22:52
Anonymous9-Jan-05 22:52 
GeneralRe: Inserting rows from data grid Pin
Paps210-Jan-05 9:47
Paps210-Jan-05 9:47 
GeneralAVICap32 API in VB.NET Pin
[DK]KiloDunse8-Jan-05 10:06
[DK]KiloDunse8-Jan-05 10:06 
GeneralRe: AVICap32 API in VB.NET Pin
[DK]KiloDunse9-Jan-05 23:51
[DK]KiloDunse9-Jan-05 23:51 
Generalsetup wizard Pin
Boniolopez8-Jan-05 4:49
Boniolopez8-Jan-05 4:49 
GeneralCallback function not working?? Video capture. Pin
[DK]KiloDunse8-Jan-05 0:37
[DK]KiloDunse8-Jan-05 0:37 
GeneralRe: Callback function not working?? Video capture. Pin
OICU8128-Jan-05 20:05
OICU8128-Jan-05 20:05 
GeneralRe: Callback function not working?? Video capture. Pin
[DK]KiloDunse8-Jan-05 20:31
[DK]KiloDunse8-Jan-05 20:31 
GeneralRe: Callback function not working?? Video capture. Pin
OICU8129-Jan-05 6:13
OICU8129-Jan-05 6:13 
GeneralRe: Callback function not working?? Video capture. Pin
[DK]KiloDunse9-Jan-05 23:50
[DK]KiloDunse9-Jan-05 23:50 
Generaldelete Pin
Makniteasy8-Jan-05 0:30
Makniteasy8-Jan-05 0:30 
GeneralRe: delete Pin
Levi Rosol8-Jan-05 4:35
Levi Rosol8-Jan-05 4:35 
GeneralRe: delete Pin
Makniteasy8-Jan-05 9:56
Makniteasy8-Jan-05 9:56 
Questionvb connect to mysql?? Pin
Ercoolz7-Jan-05 23:47
Ercoolz7-Jan-05 23:47 
AnswerRe: vb connect to mysql?? Pin
Mekong River8-Jan-05 4:25
Mekong River8-Jan-05 4:25 
QuestionThread + Closing application? Pin
DixrouE7-Jan-05 22:21
DixrouE7-Jan-05 22:21 
AnswerRe: Thread + Closing application? Pin
[DK]KiloDunse8-Jan-05 1:16
[DK]KiloDunse8-Jan-05 1:16 

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.