Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,412 members, 7,958,208 topics. Date: Wednesday, 25 September 2024 at 10:46 AM |
Nairaland Forum / Science/Technology / Programming / Visual Basic (1296 Views)
Visual Basic 2008 Express Edition / Can I Call Myself A Good Programmer If I Only Know Visual Basic / Any Visual Basic (VB) Guru In The House? (2) (3) (4)
Visual Basic by mikkytrio(m): 5:14am On Feb 18, 2010 |
please can anyone help me with codes on how to update a table from an input from in visual basic 2010 and code to create trial versions and original versions of the program am designing with visual basic 2010. |
Re: Visual Basic by fiz007: 1:15pm On Feb 18, 2010 |
wat is d question?? |
Re: Visual Basic by mikkytrio(m): 1:52pm On Feb 19, 2010 |
i am writing an application which needs to insert some values into a table unto a database and when i run it, I get an error message. Private Sub confirmBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles confirmBtn.Click 'create a new row and add data to database table If inc <> -1 Then Dim cb As New OleDb.OleDbCommandBuilder(da) Dim dsNewRow As DataRow dsNewRow = ds.Tables("addy").NewRow() dsNewRow.Item("username") = userL.Text dsNewRow.Item("password") = passL.Text ds.Tables("addy").Rows.Add(dsNewRow) da.Update(ds, "addy") MsgBox("New Record added to the Database") clearBtn.Enabled = True confirmBtn.Enabled = False End If End Sub the error message is Syntax error in INSERT INTO statement. |
Re: Visual Basic by fiz007: 7:36pm On Feb 19, 2010 |
can u paste d whole code let's c (with the database connection sting nd insert statements) |
Re: Visual Basic by s4: 12:46pm On Feb 20, 2010 |
@mikkytrio This isjust one part of your code. Try pasting the whole code, so that one can help you trace out the problem especially the part with the INSERT Statement. |
Re: Visual Basic by mikkytrio(m): 7:46pm On Feb 20, 2010 |
Imports System.Data Public Class Form1 Dim conn As New OleDb.OleDbConnection Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql1 As String Dim inc, maxrows As Integer Private Sub connect() conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\dagbo\Documents\help11.mdb.accdb" conn.Open() MsgBox("connection made" sql1 = "SELECT * FROM users" da = New OleDb.OleDbDataAdapter(sql1, conn) da.Fill(ds, "addy" End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load connect() inc = -1 maxrows = ds.Tables("addy".Rows.Count End Sub Private Sub clearBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearBtn.Click userL.Clear() passL.Clear() End Sub Private Sub addDataBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addDataBtn.Click confirmBtn.Enabled = True clearBtn.Enabled = False userL.Clear() passL.Clear() inc = 0 End Sub Private Sub confirmBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles confirmBtn.Click 'create a new row and add data to database table If inc <> -1 Then Dim cb As New OleDb.OleDbCommandBuilder(da) Dim dsNewRow As DataRow da = New OleDb.OleDbDataAdapter dsNewRow = ds.Tables("addy".NewRow() dsNewRow.Item("username" = userL.Text dsNewRow.Item("password" = passL.Text ds.Tables("addy".Rows.Add(dsNewRow) da.Update(ds, "addy" MsgBox("New Record added to the Database" clearBtn.Enabled = True confirmBtn.Enabled = False End If End Sub End Class |
Re: Visual Basic by fiz007: 9:08pm On Feb 20, 2010 |
put this code in ur confirm_Btn method, Dim stmt as String Dim con As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\dagbo\Documents\help11.mdb.accdb" stmt = ("INSERT INTO urtablename (username, password) VALUES ('" & userL.Text & "', '" & passL.Text & "')" con.Open() Dim myCmd As New OleDb.OleDbCommand(stmt, con) myCmd.ExecuteNonQuery() con.Close() |
Re: Visual Basic by mikkytrio(m): 9:59pm On Feb 20, 2010 |
ok thanks i would do so |
Re: Visual Basic by mikkytrio(m): 2:42am On Feb 21, 2010 |
that is what i have been getting all the time i try to insert.
|
Re: Visual Basic by fiz007: 8:34am On Feb 21, 2010 |
i wrote INSERT into "urtablename" urtablename means u should put the name of the table in ur access database u want to insert the values into. |
Re: Visual Basic by mikkytrio(m): 5:24pm On Feb 21, 2010 |
sorry my bad did totally forgot to change that would get back to you once i get it changed thanks |
(1) (Reply)
C#. Net Training / Help Me With C++ Assisgnment / VACANCY: Software Developer (java Enterprise-mobile Developer) WORK FROM HOME
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14 |