i have here my lines of codes. how can i use the RECORDSET.MOVELAST in VB.NET. because i need to use the rs.movelast so that my pointer will go to the last record in my database.
this line of code will increment the id depending on what is the value of the txtctr.if the value of txtctr=3 then my id will be 0001,0002,0003. - Dim objDataAdapter As New SqlDataAdapter
-
Dim objCommand As New SqlCommand
-
Dim objDataSet As New DataSet
-
Dim objDataTable As New DataTable
-
-
Dim strSelect As String
-
Dim strInsert As String
-
Dim i, j As Integer
-
Dim strid As String
-
-
Try
-
strSelect = "select * from tbluseraccess"
-
-
objDataAdapter.SelectCommand = New SqlCommand(strSelect, conn)
-
-
objDataAdapter.Fill(objDataSet)
-
-
objDataTable = objDataSet.Tables(0)
-
-
If objDataTable.Rows.Count = 0 Then
-
i = "0001"
-
Format(i, "000#")
-
Else
-
rs.movelast <<<< WHAT IS THE EQUIVALENT OF RS.MOVELAST IN VB.NET
-
i = Mid$(objDataTable.Rows(0).Item("id"), 1, 4)
-
i = i + 1
-
End If
-
-
j = 1
-
-
While j <= txtctr.Text
-
strid = Format(i, "000#")
-
strInsert = "insert into tbluseraccess (id,username,password) Values('" & strid & "','" & txtusername.Text & "','" & txtpassword.Text & "')"
-
-
With objCommand
-
strid = Format(i, "000#")
-
.Connection = conn
-
.CommandText = strInsert
-
.CommandType = CommandType.Text
-
.ExecuteNonQuery()
-
End With
-
-
j = j + 1
-
i = i + 1
-
-
End While
1 6348
i have here my lines of codes. how can i use the RECORDSET.MOVELAST in VB.NET. because i need to use the rs.movelast so that my pointer will go to the last record in my database.
this line of code will increment the id depending on what is the value of the txtctr.if the value of txtctr=3 then my id will be 0001,0002,0003.
Dim objDataAdapter As New SqlDataAdapter
Dim objCommand As New SqlCommand
Dim objDataSet As New DataSet
Dim objDataTable As New DataTable
Dim strSelect As String
Dim strInsert As String
Dim i, j As Integer
Dim strid As String
Try
strSelect = "select * from tbluseraccess"
objDataAdapter.SelectCommand = New SqlCommand(strSelect, conn)
objDataAdapter.Fill(objDataSet)
objDataTable = objDataSet.Tables(0)
If objDataTable.Rows.Count = 0 Then
i = "0001"
Format(i, "000#")
Else
rs.movelast <<<< WHAT IS THE EQUIVALENT OF RS.MOVELAST IN VB.NET
i = Mid$(objDataTable.Rows(0).Item("id"), 1, 4)
i = i + 1
End If
j = 1
While j <= txtctr.Text
strid = Format(i, "000#")
strInsert = "insert into tbluseraccess (id,username,password) Values('" & strid & "','" & txtusername.Text & "','" & txtpassword.Text & "')"
With objCommand
strid = Format(i, "000#")
.Connection = conn
.CommandText = strInsert
.CommandType = CommandType.Text
.ExecuteNonQuery()
End With
j = j + 1
i = i + 1
End While
try this rs.rows.count-1
u ll get last record
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mark Watkins |
last post by:
I know for a fact that in my database, I have three records under the users
table. However when I execute this code:
--------------BEGIN CODE----------------
Set objConn =...
|
by: tym |
last post by:
HELP!!!
I'm going round the twist with this...
I have a VB6 application which is using DAO to access a database
(Please - no lectures on ADO, I know what I'm doing with DAO!!)
Ok, problem...
|
by: AR Hall |
last post by:
This code goes through 3 work sheets in the same XL workbook, day, eve and
night shift
in each sheet their are columns representing production work orders and
reject and downtime for each order...
|
by: Henrik Larsson |
last post by:
Hi,
I need help with selecting the following rows from a table looking like this:
ID IP
Query 1 -> 1 2.2.2.2
(ie first IP 1 1.1.1.1 <- Query 2
for each...
|
by: trint |
last post by:
Ok,
Everything connects correctly and loads properly in this
WebApplication. I have four buttons and all work correctly except one
(the NEXT RECORD button). PREVIOUS, FIRST and LAST all work...
|
by: trint |
last post by:
Ok,
MoveNext is only moving to the next record once, then it stays on that
record unless I use these (which work just fine) MoveLast MoveFirst
MovePrevious.
private void btnNext_Click(object...
|
by: Steve |
last post by:
I'm hoping someone can help me out. I'm a newbie to vb.net still.
I'm trying to convert the code below from VB6 to VB.NET. I'm not sure
of the best way to go. This is basically a simple...
|
by: jodyblau |
last post by:
I'm not certain that what I am trying to do is possible; in any event I
haven't been able to figure it out. Here is what I am trying to do:
I have one table that has a list of cases I'm working...
|
by: timber910 |
last post by:
Ok, I have a button on a form that I'm using to create another table I will need later in my form. I have created a reference table called Ref_Table (holds my table names - using this as the tables...
|
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: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| | |