Updating database through datagrid vb net
Ole Db Public Class Authentication Inherits System. the code is intended for authenticate and authorize users. Perhaps this: Hi, 1) Get rid of the empty catch clause: if an exception happens you are ignoring it which make basically impossible to debug your app. Page Dim cnn As New Ole Db Connection("Provider=Microsoft. OLEDB.4.0; Data Source=c:\inetpub\wwwroot\MMORPGapi\MMORPG.mdb") Protected Sub Page_Load(By Val sender As Object, By Val e As System. It should be closed before the If statement, not IN the If statement, Finally. NET and C# When it doesn't work, you need to tell us more. If so, please tell us WHERE the error occurs and WHAT it says. Text = asd Dim username As String = "jianda" Dim pwd As String = "jiandapass" Dim SID As String = "tester" Username And Pwd Are Valid(username, pwd, SID) Response. ") End Sub Private Sub Username And Pwd Are Valid(By Val username As String, By Val pwd As String, By Val SID As String) Dim sql Str As String = "SELECT COUNT(*) AS NUMBEROFROWS FROM Credential WHERE [Username] = '" username "' AND [Password] = '" pwd "'" Dim cmd As New Ole Db Command(sql Str, cnn) Dim data Reader As Ole Db Data Reader Trace. Close() Dim online As String = "online" sql Str = "UPDATE Credential SET [Login Flag]='" online "', [Session ID]='" SID "' WHERE [Username]='" username "'" Trace. Execute Non Query() End If Catch ex As Exception Finally If Not cnn Is Nothing Then cnn. Dispose() End If End Try End Sub End Class If this comes from a book, I strongly advice you to buy another one.... Execute Reader() Dim counter As Integer Do While data Reader. To Int16(data Reader("NUMBEROFROWS")) Loop If counter = 1 Then data Reader.Applications communicate with a database, firstly, to retrieve the data stored there and present it in a user-friendly way, and secondly, to update the database by inserting, modifying and deleting data. An application accesses data either through a dataset or a data reader.
Hi, Issue is that you are not executing your update statement. It reinvents a wheel that is created by Microsoft, and it is called Forms Authentication: advanced is to use a membership provider. 2) you can check the value returned by Execute Non Query (if not 1 your where criteria is not correct) 3) also sometimes when working with db files, it does work and appears to be fine but if you don't check the actual file that has been modified, it can give the impression that the file was not updated. I already given alot of details on the very 1st post. OLEDB.4.0; Data Source=|Data Directory|c:\inetpub\wwwroot\MMORPGapi\MMORPG.mdb" But you need to read better.! You assign a SQL Statement to a sql Str string but then you execute cmd which is still a SELECT statement...
In the third type of cases, on which are going to focus this article, you may need to update the data base right after the end-user finishes modifying a single value of Rad Grid View.