473,321 Members | 1,778 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,321 software developers and data experts.

problem updating my database

hi,
i managed to populate my datagris and add a template colum to update the database. when i click the update button i get an error. is there something wrong with my code.
------------------code that populate the grid ar load

Dim conPos As SqlConnection
Dim cmdSel As SqlDataAdapter
Dim ds As DataSet

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

conPos = New SqlConnection("Server = prod01\enterprise;UID=sa;PWD=xxxx;Database=POS")

If Not Page.IsPostBack Then

BindGrid()

End If

End Sub

-----------------Bind Grid-----------------
Sub BindGrid()
cmdSel = New SqlDataAdapter("LoadOrderRegulation", conPos)

cmdSel.SelectCommand.CommandType = CommandType.StoredProcedure

cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@productName", SqlDbType.VarChar, 15))
cmdSel.SelectCommand.Parameters("@productName").Va lue = "HELLO!"
ds = New DataSet
cmdSel.Fill(ds, "Oreg")

DataGrid2.DataSource = ds.Tables("Oreg").DefaultView
DataGrid2.DataBind()
End Sub

-----------------here is the update............

' Read values of the row

Dim productNumber As String = productNumber = e.Item.Cells(0).Text
Dim storeNumber As String = storeNumber = e.Item.Cells(1).Text
Dim accountNumber As String = accountNumber = e.Item.Cells(2).Text
Dim adjustment As Integer = CType(e.Item.Cells(7).Controls(0), TextBox).Text
'this is an update stored proc

Dim cmdDA As New SqlDataAdapter("UpdateOrderRegulation", conPos)

cmdSel.UpdateCommand.CommandType = CommandType.StoredProcedure

cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@productNumber", SqlDbType.VarChar, 10))
cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@storeNumber", SqlDbType.VarChar, 10))
cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@accountNumber", SqlDbType.VarChar, 10))
cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@adjustment", SqlDbType.Int))

cmdSel.SelectCommand.Parameters("@productNumber"). Value = productNumber
cmdSel.SelectCommand.Parameters("@storeNumber").Va lue = storeNumber
cmdSel.SelectCommand.Parameters("@accountNumber"). Value = accountNumber
cmdSel.SelectCommand.Parameters("@adjustment").Val ue = adjustment

cmdSel.Update(ds, "Oreg")
DataGrid2.EditItemIndex = -1

BindGrid()

can you guys see anything wrong with my update section.

thanks

Nov 18 '05 #1
2 1433
jm
what is the error? sorry if I missed it.
"chris" <an*******@discussions.microsoft.com> wrote in message
news:D5**********************************@microsof t.com...
hi,
i managed to populate my datagris and add a template colum to update the database. when i click the update button i get an error. is there something
wrong with my code.
------------------code that populate the grid ar load

Dim conPos As SqlConnection
Dim cmdSel As SqlDataAdapter
Dim ds As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here

conPos = New SqlConnection("Server = prod01\enterprise;UID=sa;PWD=xxxx;Database=POS")


If Not Page.IsPostBack Then
BindGrid()
End If

End Sub
-----------------Bind Grid-----------------

Sub BindGrid()


cmdSel = New SqlDataAdapter("LoadOrderRegulation", conPos)

cmdSel.SelectCommand.CommandType = CommandType.StoredProcedure

cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@productName", SqlDbType.VarChar, 15)) cmdSel.SelectCommand.Parameters("@productName").Va lue = "HELLO!"

ds = New DataSet
cmdSel.Fill(ds, "Oreg")

DataGrid2.DataSource = ds.Tables("Oreg").DefaultView
DataGrid2.DataBind()


End Sub

-----------------here is the update............
' Read values of the row

Dim productNumber As String = productNumber = e.Item.Cells(0).Text
Dim storeNumber As String = storeNumber = e.Item.Cells(1).Text
Dim accountNumber As String = accountNumber = e.Item.Cells(2).Text
Dim adjustment As Integer = CType(e.Item.Cells(7).Controls(0), TextBox).Text
'this is an update stored proc

Dim cmdDA As New SqlDataAdapter("UpdateOrderRegulation", conPos)

cmdSel.UpdateCommand.CommandType = CommandType.StoredProcedure

cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@productNumber", SqlDbType.VarChar, 10)) cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@storeNumber", SqlDbType.VarChar, 10)) cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@accountNumber", SqlDbType.VarChar, 10)) cmdSel.SelectCommand.Parameters.Add(New SqlParameter("@adjustment", SqlDbType.Int))

cmdSel.SelectCommand.Parameters("@productNumber"). Value = productNumber
cmdSel.SelectCommand.Parameters("@storeNumber").Va lue = storeNumber
cmdSel.SelectCommand.Parameters("@accountNumber"). Value = accountNumber
cmdSel.SelectCommand.Parameters("@adjustment").Val ue = adjustment

cmdSel.Update(ds, "Oreg")

DataGrid2.EditItemIndex = -1

BindGrid()


can you guys see anything wrong with my update section.

thanks

---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.655 / Virus Database: 420 - Release Date: 4/8/2004
Nov 18 '05 #2
Server Error in '/pos_application' Application
-------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off"

<!-- Web.Config Configuration File --><configuration><system.web><customErrors mode="Off"/></system.web></configuration
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL

<!-- Web.Config Configuration File --><configuration><system.web><customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/></system.web></configuration
i am on a remote machine. if i am using the sa in connection string do i have to setup any security setting between iis and sql server?
Nov 18 '05 #3

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

Similar topics

4
by: Frnak McKenney | last post by:
I'm using an in-core DataSet as an image of my application's 'database' (a multi-table Access97 mdb file). Updates are made to the DataTables within the DataSet via forms with bound TextBoxes,...
1
by: Steven Blair | last post by:
Hi, Here is a short decsription of my problem. I have written a dll for Database accessing. I have one method which can return a Dataset and another method which takes a Dataset and upates a...
1
by: delta7 | last post by:
Hi, I'm new to C sharp and currently writing a small program that uses an Access 2003 database. I am currently having a problem when updating a row that includes numeric data. When updating...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
31
by: Lag | last post by:
Having a problem updating my database from a web page, through a submission form. Can anyone help? ----THIS IS MY CODE IN update.php----(user, pass, and database are typed in directly, I...
1
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and...
5
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.