473,394 Members | 1,870 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,394 software developers and data experts.

error object required at "If ((rs.Fields(0) = username.Text)..."

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.  
  3. Set conn = New ADODB.Connection
  4. conn.CursorLocation = adUseClient
  5. conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\VB98\professor_data.mdb;Persist Security Info=False;"
  6. conn.Open
  7. Set rs = New ADODB.Recordset
  8.  With rs
  9.      Set .ActiveConnection = conn
  10.         .CursorType = adOpenDynamic
  11.         .LockType = adLockOptimistic
  12.         .Source = "select * from professor_data"
  13.         .Open
  14.  
  15.  
  16.         If rs.RecordCount <> 0 Then
  17.             rs.MoveFirst
  18.             While Not rs.EOF
  19.                 If ((rs.Fields(0) = username.Text) And (rs.Fields(1) = password.Text)) Then
  20.                     MsgBox "SUCCESFUL LOGIN "
  21.                     Form1.Show
  22.                     Else
  23.                     MsgBox "INVALID USER"
  24.                 End If
  25.                 rs.MoveNext
  26.             Wend
  27.         End If
  28.  
  29.     End With
  30.  
  31.     rs.Close
  32.     Set rs = Nothing
  33. End Sub
Jan 1 '13 #1
2 2607
Ramk
61
rs.Fields(0) returns the Object type. Cast it similar to rs.Fields(0).ToString() before checking with username.Text etc. Also do check for NULL of the returned object such as
Expand|Select|Wrap|Line Numbers
  1. if (rs.Fields(0) != null)
  2. {
  3.  //your code...
  4. }
  5.  
Jan 1 '13 #2
zmbd
5,501 Expert Mod 4TB
ranjana jadhav

Posted code without explanation or question is subject to deletion. Please read the FAQ and posting guidlines before posting your question.

By, simply stating that your code "doesn't work," posting a generic/jargon filled error along with code that appears to have had very little if any troubleshooting performed, and expecting someone to help doesn't usually result in much of an answer and may result in your thread being deleted. Instead, please tell us what you were expecting to happen, what actually happened, for each error: the EXACT title, error number, and descriptions that occurred and at what line in your posted code the error occurred. These are the minimum requirements for posting a question of this nature.
Jan 1 '13 #3

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

Similar topics

4
by: Oli | last post by:
Hi Hope someone can help: <% set rsProdInfo = Server.CreateObject("ADODB.Recordset") rsProdInfo.Open "TBL_Products", Conn intTotal = 0
1
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
4
by: dubing | last post by:
Hi, Our webpage uses the following JavaScript code. function toggleSubmenu(divId, link) { var div = document.getElementById(divId); div.style.display = (div.style.display == 'block') ?...
1
by: Andrew Phillipo | last post by:
I have some code that works everywhere but IE5.0, including IE5.5. Here is a snippet of where the code seems to go wrong: Location.prototype.change = function(current) { this.current = current;...
3
by: maartha | last post by:
i have a js code which displays two html div on a click event.code is like this. function display() { document.getElementById('headingtd1').bgColor="#EFEBEF"; ...
3
by: rathiagu | last post by:
the below is my part of set cn = Server.CreateObject("ADODB.Connection") strCS = "Provider=System.Data.SqlClient; Data Source=" & _ Server.MapPath("management.mdb")& ";" cn.open strCS
2
by: Vbbeginner07 | last post by:
Please check the following code for adding records to a database: Im getting the error:object required in the following code( which is in bold letters) kindly go through Private Sub...
3
by: ShyamKrishnegowda | last post by:
We are writing test scripts to our product. In one of the script we are facing an issue. This test script will create a COM component and executes the following function. O1 and O2 are out...
1
by: ShyamKrishnegowda | last post by:
We are writing test scripts to our product. In one of the script we are facing an issue. This test script will create a COM component and executes the following function. O1 and O2 are out...
1
by: freefony | last post by:
i built a shopping software for a customer its working perfectly on my system but when i transferred to my customer's old desktop system this script throws error "object required" i tried Flock...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.