-----------------------------------------------------------
New Message on MumbaiUserGroup
-----------------------------------------------------------
From: ashok.hingorani
Message 8 in Discussion
thanks Ratish why do you want to use a databound grid to start with - why
not use a datareader object as so - should work in 2003 as well take the
UserName as an input then create an SQL statement and get the data reader to
execute it - SELECT * from Table WHERE UserName= "ABCD" and check if the name
exists. if not prompt for a change. when the username is valid and the user has
input a password again run a query SELECT * from Table WHERE UserName= "ABCD"
AND UserPassword ="ASHOK" if the query returns a record you know the password
is OK - in not then you know the pass is wrong since the name was already
checked. sample datareader code below ---------------------------------------
Dim cnSQL As SqlConnection
Dim cmSQL As SqlCommand
Dim drSQL As SqlDataReader
Dim strSQL As String
Dim objListItem As ListItem
Dim strID As String
Try
' Get Primary Key from Listbox
objListItem = CType(lstProducts.SelectedItem, ListItem)
' Build Select statement to query product information from the products
' table
strSQL = "SELECT ProductID, " & _
" ProductName, " & _
" QuantityPerUnit, " & _
" UnitPrice, " & _
" UnitsInStock, " & _
" UnitsOnOrder, " & _
" ReorderLevel, " & _
" Discontinued, " & _
" SupplierID, " & _
" CategoryID " & _
"FROM Products " & _
"WHERE ProductID = " & objListItem.ID
cnSQL = New SqlConnection(ConnectionString)
cnSQL.Open()
cmSQL = New SqlCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()
If drSQL.Read() Then
' Populate form with the data
txtProductID.Text = drSQL.Item("ProductID").ToString()
txtProductName.Text() = drSQL.Item("ProductName").ToString()
txtQtyPerUnit.Text() = drSQL.Item("QuantityPerUnit").ToString()
txtUnitPrice.Text() = drSQL.Item("UnitPrice").ToString()
txtUnitsInStock.Text() = drSQL.Item("UnitsInStock").ToString()
txtUnitsOnOrder.Text() = drSQL.Item("UnitsOnOrder").ToString()
txtReorderLevel.Text() = drSQL.Item("ReorderLevel").ToString()
chkDiscontinued.Checked = CType(drSQL.Item("Discontinued"), Boolean)
strID = drSQL.Item("SupplierID").ToString()
FindItemByID(cbSuppliers, strID)
strID = drSQL.Item("CategoryID").ToString()
FindItemByID(cbCategories, strID)
End If
' Close and Clean up objects
drSQL.Close()
cnSQL.Close()
cmSQL.Dispose()
cnSQL.Dispose()
Catch e As SqlException
MsgBox(e.Message, MsgBoxStyle.Critical, "SQL Error")
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub --------------------------------------- bst rgds ashok
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]