save to database
save to database
save to database
save to database
save to database
save to database save to database save to database save to database save to database save to database save to database save to database
save to database save to database
save to database
Go Back  Xtreme Visual Basic Talk > > > save to database


Reply
 
Thread Tools Display Modes
  #1  
Old 09-24-2008, 07:40 PM
dwkw dwkw is offline
Newcomer
 
Join Date: Sep 2008
Posts: 4
Default save to database


Please help me with my program

When the form loads it will connect to serial com and retrieve the number of chinups from a PLC and store it a variable called 'int'

there is a textbox in the form called 'txtname' and a button called 'ok'

My question is when the button is clicked, how do i store the data in variable int
to an access database according to the name typed in 'txtname'

My database has 2 tables:
1)Table1=contains username
2)Data=contains number of chinups and date

Table1 is linked to Data

How do i add a new record in Data but only from one particular username?
Attached Files
File Type: zip project.zip (20.8 KB, 1 views)
Reply With Quote
  #2  
Old 09-24-2008, 07:49 PM
HorrorGamer HorrorGamer is offline
Regular
 
Join Date: Aug 2008
Location: Surprise, AZ
Posts: 89
Default

Look into the INSERT INTO statement.
__________________
Play Tank Games
Reply With Quote
  #3  
Old 10-01-2008, 07:31 PM
dwkw dwkw is offline
Newcomer
 
Join Date: Sep 2008
Posts: 4
Default

Can you check this code:I/ve got ERROR[IM002]Data source name not found and no default driver specified.

Imports System.Data.OleDb

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim int As String = 15
Dim conn As New Odbc.OdbcConnection
Dim SqlString As String = "INSERT INTO data(chinups,date,ID) Values('" & txtname.Text & "',#" & Today.Date & "#," & CStr(int) & ")"

conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = D:\FYP\db2.mdb"
'open the connection
conn.Open()

'declare the command
Dim insertCmd As New Odbc.OdbcCommand(SqlString, conn)

'execute the command and retrieve the number of effected lines
If insertCmd.ExecuteNonQuery() > 0 Then
'everything is okay
Else
'insertion failed
End If

'close the conn
conn.Close()
End Sub
End Class
Reply With Quote
  #4  
Old 10-02-2008, 12:25 PM
wayneph's Avatar
waynephsave to database wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

Just glancing at it, I think you're using an OleDb connection string, but the ODBC database objects. Try changing over to the System.Data.OleDb Namespace for your Database Objects.
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
save to database
save to database
save to database save to database
save to database
save to database
save to database save to database save to database save to database save to database save to database save to database
save to database
save to database
 
save to database
save to database
 
-->