473,326 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Help About Rs.recordcount,movefirst,last,next In Vb.net

30
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.

Expand|Select|Wrap|Line Numbers
  1.         Dim objDataAdapter As New SqlDataAdapter
  2.         Dim objCommand As New SqlCommand
  3.         Dim objDataSet As New DataSet
  4.         Dim objDataTable As New DataTable
  5.  
  6.         Dim strSelect As String
  7.         Dim strInsert As String
  8.         Dim i, j As Integer
  9.         Dim strid As String
  10.  
  11.         Try
  12.             strSelect = "select * from tbluseraccess"
  13.  
  14.             objDataAdapter.SelectCommand = New SqlCommand(strSelect, conn)
  15.  
  16.             objDataAdapter.Fill(objDataSet)
  17.  
  18.             objDataTable = objDataSet.Tables(0)
  19.  
  20.             If objDataTable.Rows.Count = 0 Then
  21.                 i = "0001"
  22.                 Format(i, "000#")
  23.             Else
  24.                 rs.movelast  <<<< WHAT IS THE EQUIVALENT OF RS.MOVELAST IN VB.NET
  25.                 i = Mid$(objDataTable.Rows(0).Item("id"), 1, 4)
  26.                 i = i + 1
  27.             End If
  28.  
  29.             j = 1
  30.  
  31.             While j <= txtctr.Text
  32.                 strid = Format(i, "000#")
  33.                 strInsert = "insert into tbluseraccess (id,username,password) Values('" & strid & "','" & txtusername.Text & "','" & txtpassword.Text & "')"
  34.  
  35.                 With objCommand
  36.                     strid = Format(i, "000#")
  37.                     .Connection = conn
  38.                     .CommandText = strInsert
  39.                     .CommandType = CommandType.Text
  40.                     .ExecuteNonQuery()
  41.                 End With
  42.  
  43.                 j = j + 1
  44.                 i = i + 1
  45.  
  46.             End While
Mar 30 '07 #1
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
Mar 30 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
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 =...
9
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...
0
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...
8
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...
5
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...
3
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...
11
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...
2
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...
0
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
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...
0
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...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.