English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

refer question:
http://answers.yahoo.com/question/index;_ylt=Av6u5FuCM7CndEg9wd7ulMnsy6IX?qid=20060721215041AAtYDQc

Dim conn = CreateObject("adodb.connection")
Dim rs = CreateObject("adodb.recordset")
Dim comm = CreateObject("adodb.command")
Dim strSql As String

strSql = "Select User Name, Password From AuthorizedInventoryStaff.mdb Where User Name='" & txtUserName.Text & "'and Password='" & txtPassword.Text & "'"
conn.connectionstring = ""
comm.CommandType()

conn.Open()
comm.commandtext = strSql
comm.connection = conn
rs = comm.execute

If Not rs.eof Or rs.eof Then
response.redirect("Welcome.vb")
Else
response.redirect("Login.vb")
End If

error message: Name 'response' is not declared.

i ma using access and visual studio .net 2003(windows application(VB))

2006-07-21 18:59:23 · 3 answers · asked by braich_gal 3 in Computers & Internet Programming & Design

response is underlined and the error message is: Name 'response' is not declared.

2006-07-21 19:00:21 · update #1

using VB.Net

2006-07-23 07:50:56 · update #2

3 answers

pls try this simple code in asp

<%
Dim conn , rs
set conn = Server.createObject("Adodb.connection")
strConn= "[give ur database path and provider string]"
conn.open strConn
set rs = CreateObject("adodb.recordset")

Dim strSql As String

strSql = "Select User Name, Password From [TABLE NAME] Where User Name='" & txtUserName.Text & "'and Password='" & txtPassword.Text & "'"
on error resume next
rs.open strSql, conn,2,3
if len(err.description)<> 0 then
Response.Write("Check ur sql")
end if

If Not rs.eof Or rs.eof Then
response.redirect("Welcome.vb"...
Else
response.redirect("Login.vb")
End If
%>

hope this will help u out
other wise pls send me the error i will see it

bye

2006-07-22 00:32:48 · answer #1 · answered by amit_shri05 2 · 0 0

The response object is part of a web application.
It will not be available to a windows application.
You should not be using createobject in a .net windows application.

ASP has nothing to do with a .net windows application.

To do what you wish in a .net windows application:

Imports System.Data.OleDb

Public Class Form1
Public cn As New OleDbConnection
Public connectstring As String = String.Empty
Public cmd As New OleDbCommand
Public dr As OleDbDataReader



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strName As String = String.Empty
Dim strPassword As String = String.Empty

'strname=txtname.text
'strpassword=txtpassword.text

'create your connection.
'replace the datasource with a path to your mdb
'the connectionstring line has been broken up to display
'completely. It should all be on one line.
connectstring = "Provider=
Microsoft.Jet.OLEDB.4.0;
Data Source=\somepath\mydb.mdb;
User Id=admin;Password=;"
cn.ConnectionString = connectstring
cn.Open()
'associate the connection to the command object
cmd.Connection = cn
'set your sql
cmd.CommandText = "select * from accesstable where name='" & strName & "' and password='" & strPassword & "'"
'set the datareader= to the command object's executereader method results
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
'close your connection
If dr.HasRows Then
'there was a record with that username
'since this is a windows application - there is no such thing as redirect.
'you have to have created a login form, and a welcome form.

'close the datareader
dr.Close()
cn = Nothing
cmd = Nothing
dr = Nothing

'**** Go to welcome form *************
'frmWelcome.activeate
Else
If Not dr.IsClosed Then dr.Close()
MsgBox("invalid username and password", MsgBoxStyle.OkOnly, "Login Failed")
'since this is the login form - no need to go anywhere else


End If


End Sub
End Class

2006-07-22 10:05:53 · answer #2 · answered by ZressE 3 · 0 0

hi,

your mistake is in
Select User Name, Password From AuthorizedInventoryStaff.mdb Where User

AuthorizedInventoryStaff.mdb - should be the table that holds the authorized staff information. If AuthorizedInventoryStaff is the name of the table then try to take off the ".mdb"

2006-07-23 12:45:23 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers