hi all this is the code - Public Class Form2
-
Dim mycone As New OdbcConnection("myconection")
-
Dim mycmnd As New OdbcCommand
-
Dim mydr As OdbcDataReader
-
Dim str() As String
-
Dim arrcnt As Long
-
'Dim mysqlstr As String
-
-
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
Dim reccount As Long
-
Dim i As Long
-
mycmnd = New OdbcCommand("select EmpName from empdetails", mycone)
-
mycone.Open()
-
mydr = mycmnd.ExecuteReader
-
If mydr.HasRows > 0 Then
-
reccount = mydr.HasRows - 1
-
ReDim str(reccount)
-
For i = 0 To reccount
-
str(i) = mydr(0)
-
mydr.NextResult()
-
Next
-
-
End If
-
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
Dim i As Integer
-
arrcnt = UBound(str) this is showing me error here
-
mycmnd.CommandType = CommandType.Text
-
For i = 0 To arrcnt
-
mycmnd.CommandText = "insert into checkout (EmpName) values ('" & str(i) & "')"
-
mycone.Open()
-
mycmnd.ExecuteNonQuery()
-
mycone.Close()
-
Next
-
End Sub
-
End Class
6 1063
hi all this is the code - Public Class Form2
-
Dim mycone As New OdbcConnection("myconection")
-
Dim mycmnd As New OdbcCommand
-
Dim mydr As OdbcDataReader
-
Dim str() As String
-
Dim arrcnt As Long
-
'Dim mysqlstr As String
-
-
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
Dim reccount As Long
-
Dim i As Long
-
mycmnd = New OdbcCommand("select EmpName from empdetails", mycone)
-
mycone.Open()
-
mydr = mycmnd.ExecuteReader
-
If mydr.HasRows > 0 Then
-
reccount = mydr.HasRows - 1
-
ReDim str(reccount)
-
For i = 0 To reccount
-
str(i) = mydr(0)
-
mydr.NextResult()
-
Next
-
-
End If
-
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
Dim i As Integer
-
arrcnt = UBound(str) this is showing me error here
-
mycmnd.CommandType = CommandType.Text
-
For i = 0 To arrcnt
-
mycmnd.CommandText = "insert into checkout (EmpName) values ('" & str(i) & "')"
-
mycone.Open()
-
mycmnd.ExecuteNonQuery()
-
mycone.Close()
-
Next
-
End Sub
-
End Class
Hi. Replace arrcnt with
and don't use the UBound function.
Normal use of a recordset or datareader would be to read it directly into the sql statement. Transferring to an array, in this case, does not appear to provide any benefit. Just wastes time and introduces possible exceptions.
You can also eliminate most of the code with - "insert into checkout (checkout.EmpName) select empdetails.EmpName from empdetails"
...Normal use of a recordset or datareader would be to read it directly into the sql statement. Transferring to an array, in this case, does not appear to provide any benefit. Just wastes time and introduces possible exceptions. ...
But why would arrcnt = UBound(str) produce an error? And seshu, what error did it produce? When reporting an error, always include the details - they are supremely important.
But why would arrcnt = UBound(str) produce an error? And seshu, what error did it produce? When reporting an error, always include the details - they are supremely important.
Whether or not str has a subscript is conditional upon there being a number of records to initialise it. UBound will fail without an array with subscripts as a parameter. The initial declaration, str(), is just a placeholder and not an array.
Whether or not str has a subscript is conditional upon there being a number of records to initialise it. UBound will fail without an array with subscripts as a parameter. The initial declaration, str(), is just a placeholder and not an array.
Interesting - I thought it would just return zero. We live and learn...
Hi. Replace arrcnt with
and don't use the UBound function.
Normal use of a recordset or datareader would be to read it directly into the sql statement. Transferring to an array, in this case, does not appear to provide any benefit. Just wastes time and introduces possible exceptions.
sir from this statement - "insert into checkout (checkout.EmpName) select empdetails.EmpName from empdetails"
will all the records in my table1will be moveing to table2
hope this goes well
i will check it if it fails i think i should take an array right
help me out sir
will all the records in my table1will be moveing to table2
hope this goes well
i will check it if it fails i think i should take an array right
help me out sir
There is no reason to use an array or recordset. use the statement I gave you and it will work
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mariusz Jedrzejewski |
last post by:
Hi,
I'll be very grateful if somebody can explain me why my Opera 7.23
(runing under linux) doesn't show me inner tables. Using below code I
can see only "inner table 1". There is no problem with...
|
by: ALESSANDRO Baraldi |
last post by:
Hi and good evening.
I need to show with Lebans RichTextBox a Mime decoded Message.
I build an Mail Receiver, with MIME conversion.
To show Html Message i think that it's need to rtf...
|
by: ATS |
last post by:
I'm trying to set up a slide show on a web page using Javascript. Here is
the code I have so far:
<script language="javascript">
alert("**in test area 1");
slides = new Array();
slides =...
|
by: =?Utf-8?B?bGpsZXZlbmQy?= |
last post by:
I need to show a custom control in the DropDown of a
Windows.Forms.ToolStripMenuItem (e.g., similar to the Font Color menu item in
Word except that the control is specific to my application). I...
|
by: duke123 |
last post by:
Hi,
I have two divs (image & story) both positioned in a manner so that one overlays the other. The purpose of the code below is to hide one and show the other on a button click. So whenever we...
|
by: bimeldip |
last post by:
Hi,
I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
|
by: qutspan |
last post by:
When I create taskbox on the form the line beside the box wont show up.
it show up untill I have MouseEnter event occur.
Also when I have 2 taskbox on the form it does draw the line around the...
|
by: ABHIJIT B |
last post by:
Hi,
I am using GridView in my web form and binding DataTable in code
behind file as given below.
gvUsersList.DataSource = dtUserList;
gvUsersList.DataBind();
If no records exists in...
|
by: janetopps |
last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |