473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Data Access Issues

I'm trying to update a table on a SQL Server from a web page. I'm not having any problems reading the data, but I can't seem to update it. From the code below can someone please tell me what I'm missing? I'm sure I've kludged it up a bit with all my attempts. Thanks.

Dim sFileName As String
sFileName = Now.Millisecond & Now.Second & Now.Minute & Now.Hour & Now.Year & Now.Month & Now.Day

Dim sqlCnxn As New SqlConnection("user id=SomeUser;password=Pswd;data source=DATASERVER")
Dim daFiles As New SqlDataAdapter("SELECT * FROM FD_Files", sqlCnxn)
Dim dsFiles As New DataSet()
Dim custCB As SqlCommandBuilder = New SqlCommandBuilder(daFiles)

daFiles.Fill(dsFiles, "FD_Files")
Dim dr As DataRow = dsFiles.Tables(0).NewRow
dr("FileName") = Path.GetFileName(txtFile.PostedFile.FileName)
dr("ExpireTime") = Now.AddHours(24)
dr("PostedBy") = Session("UserAlias")
dr("HashName") = sFileName
dr("FileSize") = txtFile.PostedFile.ContentLength / 1024
dr("Description") = txtDescription.Text
dsFiles.Tables(0).Rows.Add(dr)
dsFiles.AcceptChanges()
daFiles.Update(dsFiles, "FD_Files")
Nov 18 '05 #1
1 912
It helps if you generate the SQL Commands after you add the rows to the table... I knew it had to be an easy fix.

Jerry
"Jerry Camel" <rl*****@msn.com> wrote in message news:Ou**************@tk2msftngp13.phx.gbl...
I'm trying to update a table on a SQL Server from a web page. I'm not having any problems reading the data, but I can't seem to update it. From the code below can someone please tell me what I'm missing? I'm sure I've kludged it up a bit with all my attempts. Thanks.

Dim sFileName As String
sFileName = Now.Millisecond & Now.Second & Now.Minute & Now.Hour & Now.Year & Now.Month & Now.Day

Dim sqlCnxn As New SqlConnection("user id=SomeUser;password=Pswd;data source=DATASERVER")
Dim daFiles As New SqlDataAdapter("SELECT * FROM FD_Files", sqlCnxn)
Dim dsFiles As New DataSet()
Dim custCB As SqlCommandBuilder = New SqlCommandBuilder(daFiles)

daFiles.Fill(dsFiles, "FD_Files")
Dim dr As DataRow = dsFiles.Tables(0).NewRow
dr("FileName") = Path.GetFileName(txtFile.PostedFile.FileName)
dr("ExpireTime") = Now.AddHours(24)
dr("PostedBy") = Session("UserAlias")
dr("HashName") = sFileName
dr("FileSize") = txtFile.PostedFile.ContentLength / 1024
dr("Description") = txtDescription.Text
dsFiles.Tables(0).Rows.Add(dr)
dsFiles.AcceptChanges()
daFiles.Update(dsFiles, "FD_Files")
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Frnak McKenney | last post by:
Back when computer dinosaurs roamed the earth and the precursors to today's Internet were tiny flocks of TDMs living symbiotically with the silicon giants, tracking access to data processing...
32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
2
by: Riegn Man | last post by:
I have a problem with access and our time clocks. We have time clocks that put out a .log file with the badge swipes for everybody. There is one .log file for each day. I am pulling that data...
1
by: Nikki | last post by:
I have a database, front and data backend, I have written in Access 97 and it has been chugging along for the last 6 years all with constant updates except for the last year with almost no...
0
by: Thomas Anderson | last post by:
I have had this database up for several months and suddenly I began getting "Data type mismatch in criteria expression" Errors all over the place. I can open a query and get this error, then say...
9
by: AnandaSim | last post by:
Hi All, I've had Access 97, 2000 connections to the corporate Oracle database for a few years now - but seldom use it. When I did use it years ago, performance was not fast but the features were...
16
by: Andy_Khosravi | last post by:
I'm in a bit of a pickle. My employer, a health insurance firm, had me design a small database to track benefit issues. The intended users were technical specialists and some managers (about 90...
4
by: Craig HB | last post by:
I have an Access 2002 database that uploads data into a SQL Server 2000 database using DTS. Each upload includes 5 tables of up to 1000 rows. This is a weekly upload that takes place in about 250...
4
by: George | last post by:
Hi all, I am having trouble with updating my data in an Access database. here is my code: Imports System.Data.OleDb Dim AppPath As String = Mid(Application.ExecutablePath, 1,...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.