dilbert0610
Member
- Joined
- Aug 3, 2006
- Messages
- 22
- Programming Experience
- Beginner
Hello. I am new to data access with vb.net. I have done extensive work with php and data access, but this is new to me. I can connect to the database but from there im lost. I looked over a few examples but just couldnt get them working.
That is what I currently have. When I run this I get this error:
I tried using the example from here :
http://www.vbdotnetforums.com/showthread.php?t=11449&highlight=sql+statement+to+text+box
He was trying to help someone so I was readin the code and was attempting that. But when I would get to the point where I would need:
I would get errors saying that columnOrdinal needed to be declared.
If anyone could give me a few pointers I would appreciate it.
Thanks
VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button1.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myConn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Odbc.OdbcConnection[/SIZE]
[SIZE=2]myConn.ConnectionString = "ServerDSN=MAC;TransportHint=TCP:SPX;DSN=MAC;ArrayBufferSize=8;ArrayFetchOn=1;ServerName=manmac.1583;UID=****;DecimalSymbol=."[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sql [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = "SELECT Item_No FROM IMITMIDX_SQL"[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ad [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Odbc.OdbcCommand(sql, myConn)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] reader [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Odbc.OdbcDataReader[/SIZE]
[SIZE=2]myConn.Open()[/SIZE]
[SIZE=2]reader = ad.ExecuteReader[/SIZE]
[SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] reader.Read[/SIZE]
[SIZE=2]lstMain.Items.Add(reader.GetString(1))[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE]
[SIZE=2]myConn.Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
That is what I currently have. When I run this I get this error:
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
Additional information: Index was outside the bounds of the array
I tried using the example from here :
http://www.vbdotnetforums.com/showthread.php?t=11449&highlight=sql+statement+to+text+box
He was trying to help someone so I was readin the code and was attempting that. But when I would get to the point where I would need:
VB.NET:
nrow(columnOrdinal) = myreader.getvalue(columnordinal)
I would get errors saying that columnOrdinal needed to be declared.
If anyone could give me a few pointers I would appreciate it.
Thanks