473,395 Members | 1,464 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,395 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 1438
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.