Question about Microsoft Computers & Internet

1 Answer

Vb 6.0 ado connection without ado control moving next record

Here is my code

nothing is happen when i am clicking
or some times only one record is moved for move next

Private Sub cmdnext_Click()
Dim st As String
Dim que As String
Dim con As ADODB.Connection
Dim REC As ADODB.Recordset
st = "provider=microsoft.jet.oledb.4.0;Data source=" + App.Path + "db1.mdb"
Set con = New ADODB.Connection

With con
.ConnectionString = st
.Open
End With
que = "select * from class_add where class='" + cmbedit.Text + "'"
Set REC = New ADODB.Recordset
REC.Open que, con, adOpenDynamic, adLockReadOnly



REC.MoveNext
If Not REC.BOF Then REC.MoveNext

txtclass.Text = REC("class")
txtteacher.Text = REC("claasteacher")
txtleader.Text = REC("leader")
totstd.Text = REC("totstd")
txtsubj.Text = REC("no_subj")
txtroom.Text = REC("room_no")

End If
End Sub
thank you for spending your time

Posted by on

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that got 5 achievements.

    Novelist:

    An expert who has written 50 answers of more than 400 characters.

    Scholar:

    An expert who has written 20 answers of more than 400 characters.

  • Expert
  • 160 Answers

I see 2 problems with your code.

1) Each time you call cmdnext_Click, you're reopening the database. Each time you do that, you start at the beginning of the file. You need to have the database opened once, somewhere else in your program. Be sure that the record set is visible from this sub.

2) In order to use the "Next" function, you need a loop like this

'test for no records
IF REC.BOF and REC.EOF then
msgbox "No Records Found"
exit sub
end if

IF NOT REC.EOF then
REC.MoveNext
(display your fields)
END IF


Again, this will only work if your database is opened outside of the cmdNext_Click routine.

Posted on Jul 16, 2008

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

How to detect microphone in laptop


Hi,

I think it would be better if we check that the built-in microphone is working on your machine.

Internal microphone

The internal microphone is located near the top of the notebook LCD display or near the bottom of the LCD display near the hinge. Use the following best practices to better capture sound with the microphone.

-Adjust the notebook PC screen to place the microphone in the best direction for receiving sound.

-Speak directly into the microphone. Avoid speaking away from the microphone.

-When using the internal microphone, choose an environment without background noise.


Testing the record function on the notebook PC

1. Click Start , then Programs , Accessories , Entertainment , and then Sound Recorder .
2. Click Record (the red dot) and speak into the microphone.
3. When you are finished recording, click Stop (the gray rectangle).
4. To play back the recording, click Play (the gray arrow pointing to the right).

If happens that the recording with the microphone have no sound we have check the settings.

Checking microphone settings

1. Click Start , then Programs , Accessories , Entertainment , and then Volume Control .
2. A Volume Control or Master Volume window opens.
3. Click Options , and then Properties .
4. Select Recording , and make sure Microphone is selected.
5. Click OK . The Volume Control window should change to a Recording Gain Control window.
6. Click Options again and then click Advanced Controls . If Advanced Controls is unavailable, then an alternate microphone is not available. Proceed to the next series of steps.
7. Remove the check next to Alternate microphone , click Close , and test the microphone. If there is still no sound, continue to the next step

Ensuring the correct recording device is selected

1. Access sound properties:

-In Windows XP, to access the sound control panel applet, click Start , then Control Panel . Click Sounds, Speech, and Audio Devices , and then click Sounds and Audio Devices .

-In Windows 95, 98, and Me, click Start , Settings , and Control Panel . Double-click Sounds and Multimedia , or Multimedia . The Sounds and Multimedia Properties window opens.

2. Click the Audio tab.

3. Under Sound Playback , select the audio device that is installed on the computer (there should be only one).

4. Under Sound Recording , select the audio device that is installed on the computer. It should be the same as the listing under Sound Playback .

5. Click OK .

6. Close the Sound and Multimedia Properties window and test the recording.


Feel free to reply if happens the steps I've told you is not working. Hope it helps.

AnEspera

May 03, 2011 | HP Pavilion dv4000 Notebook

1 Answer

Adodb connection


In VB6 you would use ADODB. This is for ADO and is used for accessing data (read, write, update, etc.) from different data sources. Your connection string will vary based on the data source you need to connect to. Here is an example for a SQL connection:

"Provider=SQLOLEDB;Data Source=your_server;Initial Catalog=your_database;User ID=sa;Password=your_password;"

For VB.NET you would be using the ADO.NET toosl and a connection string as well.

Apr 27, 2009 | Computers & Internet

1 Answer

How to access data from ms access with buffer in class code with vb application


Use ADO and create a connection string for a Jet file (version matters here when creating the string). Then use ADO commands and return recordsets to buffer your data.

Mar 26, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

Speed problem while retrieving data


I assume you are using a current ADODB version.

1) Your code is not compiled on the SQL side so it will be slower

2) Is there a purpose to the code or is it just an exercise? You can write cleaner code for a move next, move previous, move first or move last statement. These are standard methods in VB 6.

3) I would write a few simple procs with a return code. Much faster, cleaner.


Good luck

Mar 25, 2009 | Computers & Internet

1 Answer

How to connect vb with ms access


se Adodc OR Even better.. ADODB. for this you need to get MDAC fromMicrosoft free download.(check under project_References- Microsoft DataActiveX objects.. the current no is 2.8. if it is not there download invb directory.

next, you can learn about creating a DSN from control panel, ODBC. onceyou learn this, connection becomes a piece of cake. get some free vbtutoriasl from WWW.

then

you need to use DAO or ADO to connect to the database. better study both but since ADO is current, i am showing that code.
under Menu Project_References, put a check mark on Microsoft ActiveXData Objects latest version (though it works for all, currently 2.8with sp pack 1 ).

at the general declarations:
dim conn as adodb.connection, rec as adodb.recordset, esql as string,esql1 as string
Private Function connect()
Set rec = New ADODB.Recordset
Set conn = New ADODB.Connection
esql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "D:VBDesigndhana2.mdb" & ";Persist Security Info=False"
'here you put the correct path of your mdb file. and check if you have jet 4.0

conn.Open (esql), , , 0
End Function

private sub form_Load()
connect
end sub
and for adding records:
say let us say you have 3 fields. then have 3 textboxes and 1 command button on the form.

private command1_click()
esql1="select * from Yourtablename"
rec.open(esql1),conn,, adOpenDynamic, adLockOptimistic
rec.AddNew
rec.Fields(0) = text1.Text
rec.Fields(1) = Text2.text
rec.Fields(2) = text3.text
' you need to check if in your access table design you have Allowed Zero length .. set it to Yes for all text fields.
rec.update
if not rec.eof then rec.movenext
rec.close
conn.close
set conn to nothing
end sub

this will add new records to access table from VB.
' for picture store the full path of the path and the picture file nameint the text field. and in the picturebox of VB form for viewingrecords again you need ADO or ADODC and here you code:picture1.picture=Loadpicture(rec.fields(3) ' depending on where thepicture field is located. you need to make a few trials.
under Menu Project_References, put a check mark on Microsoft ActiveXData Objects latest version (though it works for all, currently 2.8with sp pack 1 ).

at the general declarations:
dim conn as adodb.connection, rec as adodb.recordset, esql as string,esql1 as string

Private Function connect()
Set rec = New ADODB.Recordset
Set conn = New ADODB.Connection
esql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "D:VBDesigndhana2.mdb" & ";Persist Security Info=False"
'here you put the correct path of your mdb file. and check if you have jet 4.0

conn.Open (esql), , , 0
End Function

private sub form_Load()
connect
end sub

and for accessing records:

private command1_click()
esql1="select * from Yourtablename where id =" & val(text1) ' for integers

esql1="select * from Yourtablename where name=" & "'" & text1 & "'" ' for string

rec.open(esql1),conn, adOpenstatic, adLockreadonly

label1.caption =rec.Fields(0)
label2.caption= rec.Fields(1)
label3.caption= rec.Fields(2)
' you need to check if in your access table design you have Allowed Zero length .. set it to Yes for all text fields.

rec.close
conn.close
set conn to nothing
end sub


' similarly there are routines to ADD, Delete, Edit, View etc.

Feb 26, 2009 | Computers & Internet

1 Answer

Book mark property of recordset (ado)


The bookmark property of a recordset lets you store and retrieve the location of a record in a variable so that you can move directly to it in your recordset without having to use a query to extract that record. Like you can just move forward a record and back a record, or move to the first or last records without a quesry statement, you can move to the bookmarked record directly in code.

Here's a good VB example that compares the bookmakr property to the movefirst and movelast properties. This should answer your question, and please rate my answer.

'BeginBOFVB 'To integrate this code 'replace the data source and initial catalog values 'in the connection string Public Sub Main() On Error GoTo ErrorHandler 'recordset and connection variables Dim Cnxn As ADODB.Connection Dim rstPublishers As ADODB.Recordset Dim strCnxn As String Dim strSQLPubs As String 'record variables Dim strMessage As String Dim intCommand As Integer Dim varBookmark As Variant ' open connection Set Cnxn = New ADODB.Connection strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _ "Initial Catalog='Pubs';Integrated Security='SSPI';" Cnxn.Open strCnxn ' Open recordset and use client cursor ' to enable AbsolutePosition property Set rstPublishers = New ADODB.Recordset strSQLPubs = "SELECT pub_id, pub_name FROM publishers ORDER BY pub_name" rstPublishers.Open strSQLPubs, strCnxn, adUseClient, adOpenStatic, adCmdText rstPublishers.MoveFirst Do Until rstPublishers.EOF ' Display information about current record ' and get user input strMessage = "Publisher: " & rstPublishers!pub_name & _ vbCr & "(record " & rstPublishers.AbsolutePosition & _ " of " & rstPublishers.RecordCount & ")" & vbCr & vbCr & _ "Enter command:" & vbCr & _ "[1 - next / 2 - previous /" & vbCr & _ "3 - set bookmark / 4 - go to bookmark]" intCommand = Val(InputBox(strMessage)) ' Check user input Select Case intCommand Case 1 ' Move forward trapping for EOF rstPublishers.MoveNext If rstPublishers.EOF Then MsgBox "Moving past the last record." & _ vbCr & "Try again." rstPublishers.MoveLast End If Case 2 ' Move backward trapping for BOF rstPublishers.MovePrevious If rstPublishers.BOF Then MsgBox "Moving past the first record." & _ vbCr & "Try again." rstPublishers.MoveFirst End If Case 3 ' Store the bookmark of the current record varBookmark = rstPublishers.Bookmark Case 4 ' Go to the record indicated by the stored bookmark If IsEmpty(varBookmark) Then MsgBox "No Bookmark set!" Else rstPublishers.Bookmark = varBookmark End If Case Else Exit Do End Select Loop ' clean up rstPublishers.Close Cnxn.Close Set rstPublishers = Nothing Set Cnxn = Nothing Exit Sub ErrorHandler: ' clean up If Not rstPublishers Is Nothing Then If rstPublishers.State = adStateOpen Then rstPublishers.Close End If Set rstPublishers = Nothing If Not Cnxn Is Nothing Then If Cnxn.State = adStateOpen Then Cnxn.Close End If Set Cnxn = Nothing If Err <> 0 Then MsgBox Err.Source & "-->" & Err.Description, , "Error" End If End Sub 'EndBOFVB

Jan 07, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

Access-VB


Use this line below:

Private Sub CommandButton_Click()

Dim NumericValue as Integer
Dim StringValue as String

NumericValue = CInt(TextField1)
StringValue = TextField2

DoCmd.RunSQL "INSERT INTO NameOfTable ( [FieldName1], [FieldName2]) VALUES (" & NumericValue & " , '" & StringValue & "');"

EndSub

I Hope this work for you... God Bless

Jul 16, 2008 | Microsoft Office Access 2003 (077-02871)...

1 Answer

Codes


You would code using ADO (for VB6) or ADO.NET for VB.NET and other .NET languages.

May 27, 2008 | Canon VB-C10 / VB-C10R Network Camera

2 Answers

Linking vb to access


You post it in the wrong product, you should have posted it in Access or Office. But I will try to answer anyways...

In tools look for references and then look for MS ADO Data Control 6.0 or Microsoft ADO... Just select it and press ok then you will have a new control object name "ADO data control". See the explanation about the ado data control which is very easy to use...

Here is also a great tutorial for the ADO Data Control:
http://www.devarticles.com/c/a/Visual-Basic/Implementing-An-ADO-Data-Control-With-VB6/

You can also use VBA in Access, you have exactly the same functions there as well.

Sep 19, 2007 | Adobe Photoshop CS2 for PC

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

1,182 people viewed this question

Ask a Question

Usually answered in minutes!

Top Microsoft Computers & Internet Experts

micky dee

Level 3 Expert

2642 Answers

Les Dickinson
Les Dickinson

Level 3 Expert

18375 Answers

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...