Updating database from datagridview in 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....

Using bind variables also improves query performance in the database, eliminates the need for special handling of literal quotation marks in the input, and protects against SQL injection attacks.

When you start reading the code from the beginning, there is an when making calls to the SQL server list, databases, and tables.

This is done because only one call back method handles all call backs from async calls.

Hi all, I am unable to do an update data to my ms access database table. Need to configure some setting on the ms access DB for update statement? I couldnt see that you are executing the update statement anywhere in your code. By default, the build in Membership provider uses a SQL Server (Express) Database, but you can use Access as well: Hi hans_v. I am trying to do a simple prototype so could u be kind enough to help me solve my problem with Updating data to the MS access database? Sometimes, the db file is even deployed again on the next build giving the impression that the changes were not permanent. There is no error when i run my aspx but i just don't see my database updated with the new data. i did a breakpoint and i realise cmd.executenonquery return a 0 which mean the update is not succesfull.. " You modified the path in the connectionstring from "Provider=Microsoft. OLEDB.4.0; Data Source=c:\inetpub\wwwroot\MMORPGapi\MMORPG.mdb" TO "Provider=Microsoft. In order to use the Data Directory Directive, Mike writes: And then your connectionstring should look like: "Provider=Microsoft. OLEDB.4.0; Data Source=|Data Directory|MMORPG.mdb" By the way, next time, please don't post pictures, but show the relevant code and the eroor message you get I don't see any of your screenshots. Waht if you insert a cmd=new Ole Db Command(str Sql,cnn) to recreate the cmd object for your new SQL statement... Close() Dim online As String = "online" sql Str = "UPDATE Credential SET [Login Flag]='" online "', [Session ID]='" SID "' WHERE [Username]='" username "'" Trace.

After i run my .aspx, i check the database table but still data not updated. You can use Execute Non Query method to execute the update query You can modify and use the below code Thanks for helping Terry! My database consist of a table called Credential with 4 fields Username, Password, Login Flag and Session ID SELECT STATEMENT seems fine but UPDATE is NOT working. Select statement is fine so the connection to the ms database is working fine. So if #1 and #2 doesn't help, double check which file exactled is used by your app... i try with and without WHERE clause but still cannot update. Write(sql Str) cmd=new Ole Db Command(str Sql,cnn) ' Added cmd. However, this was in his original cide, which should better not be used...