DataSource Controls :: Save Values In GridView With 2 Tables

May 29, 2010

I have a form with several DropDownlists and TextBoxes, Each dropdownlist depends on the selection of the previouse one.. and there is a submit button. Once the user clicks on it, information entered by the user is displayed in a GridView and saved as well in the database. The GridView holdes information from two tables I used joining) , but once I click on the Submit button I receive this error: Arithmetic overflow error converting varchar to data type numeric. The statement has been terminated. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Arithmetic overflow error converting varchar to data type numeric. The statement has been terminated. Source Error:

[Code]....

Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial
Class Members_MembersCalculator
Inherits System.Web.UI.Page
Protected Sub CalculateButton_Click(ByVal sender
As Object,
ByVal e As System.EventArgs)
Handles CalculateButton.Click
Dim objConnection As SqlConnection
Dim objDataCommand As SqlCommand
Dim c_manu, c_model, c_date
As String
Dim sSQL As
String
Dim ConnectionString As
String
Dim c_factor As
Double
Dim c_result
As Double
Dim c_milage As
Double
Dim c_id As
Integer
Dim c_year As
Integer
c_manu = ManDropDownList.Text
c_year = YearDropDownList.Text
c_model = ModelDropDownList.Text
c_milage = MilageTextBox.Text
c_factor = FactorDropDownList.Text
c_id = CarIDDropDownList.Text
c_date = CarDateTextBox.Text
c_result = c_factor * c_milage
ConnectionString = WebConfigurationManager.ConnectionStrings("Carbon_free_ConnectionString").ConnectionString
objConnection = New SqlConnection(ConnectionString)
objConnection.Open()
sSQL = "Insert into car (Manufacture, year, Model, car_factor)" & _
"values('" & c_manu &
" ', ' " & c_year & " ',' " & c_model &
" ', ' " & c_factor &
" ')"
objDataCommand = New SqlCommand(sSQL, objConnection)
objDataCommand.ExecuteNonQuery()
objConnection.Close()
objConnection = New SqlConnection(ConnectionString)
objConnection.Open()
sSQL = "Insert into car_Result (car_id, car_Result_Date, Car_result)" & _
"values('" & c_id &
" ', ' " & c_date & " ',' " & c_result &
" ')"
objDataCommand = New SqlCommand(sSQL, objConnection)
objDataCommand.ExecuteNonQuery()
objConnection.Close()
msgLabel.Text = "Your records have been calculated successfuly, Thank you."
'CarDateTextBox.Text = ""
'MilageTextBox.Text = ""
CarGridSqlDataSource.DataBind()
CarGridView.DataBind()
End Sub
End
Class

View 3 Replies


Similar Messages:

DataSource Controls :: Adding The Same Data Values Into 2 Tables

Apr 23, 2010

i have an insert statement, and what i would like to do iswhen the value of table1 is entered, that value enters into table 2, so for example, heres my insert statement

INSERT INTO Cards (Name, Desc, id) VALUES ( @Name, @Desc, @id) INSERT INTO CardTP (NameSet, Desc, id)

Now, what i would like to do is that, i will specify all those individual values myself, BUT, when it now comes to the "id" field, when an id is entered for the "Cards" table, the SAME id should also be entered in the id column of the "CardTP" table. how i could enter the value of one table, into another tables row (having the same value) as i want the Cards and CardsTP table to be related in the id fields.

View 3 Replies

Data Controls :: How To Save GridView Row Values On By One To Database

May 7, 2015

I want to add the text box values to grid one by one and next i want to submit all grid values for insert.

View 1 Replies

Forms Data Controls :: Save Values In Editable Gridview?

Feb 18, 2010

I have an editable gridview with blank cells. User enters some numeric data in cells and also user can clicks a button to add new row to gridview. My problem is that, as soon as button click event is fired, the page refreshes & the gridview becomes empty. Can anybody tell me, how can I save values in gridview until the user saves all changes to the server in the end

View 3 Replies

Data Controls :: Save GridView Column Values To ViewState

Sep 20, 2015

ViewState["Index"] = reader[0].ToString();

Using sqlDataAdapter, I wanna save one column to view state like this.

View 1 Replies

Data Controls :: Save Checked Checkbox Values Into Database Which Is Inside GridView

Dec 23, 2015

I have a gridview inside which there are 4-5 checkboxes. In that gridview, I have 10 rows too. So, Now what i want is.

IF I check, 2 checkboxes and don't check remaining checkboxes. how to save the value of the checked checkboxes value as Y and unchecked checkboxes value as N into the database.

Below is the HTML of the checkboxes here:-

 <cc2:Grid ID="GrdRights" runat="server" FolderStyle="../Styles/Grid/style_12"
AllowSorting="False" AutoGenerateColumns="False" AllowColumnResizing="true" AllowAddingRecords="false"
AllowMultiRecordSelection="true" OnRowDataBound="GrdRights_RowDataBound" ViewStateMode="Enabled"
PageSize="100">
<ClientSideEvents OnClientSelect="FunMonthList" />
<ScrollingSettings ScrollHeight="400px" />

[Code] .....

View 1 Replies

Forms Data Controls :: How To Draw Bar Charts Dynamically Retrieving Values From Values Of Different Tables

Feb 1, 2011

I am using VS 2005.I have 5 tables depending on their values ,I need to draw a bar chart.

View 1 Replies

Forms Data Controls :: Gridview - Save Selected Values And Checked Boxes In Database

Feb 2, 2010

I have a gridview and users would select some records and would click on the submit button and i will be saving those records into database using a stored proc.... now .... just below the gridview and above the submit button there are few checkboxes by default they wud be checked. How would i save the selected values and the checked boxes in database i wrote the stored proc for the gridview but how would i save the checked checkboxes into the same table.

For i As Integer = 0 To gvSelectScreen.Rows.Count - 1
Dim chkTemp As CheckBox = TryCast(gvSelectScreen.Rows(i).FindControl("cbStatus"), CheckBox)
If chkTemp.Checked Then
ContractNumber = gvSelectScreen.Rows(i).Cells(0).Text
ClientProgramNumber = gvSelectScreen.Rows(i).Cells(1).Text
ClientProgramName = gvSelectScreen.Rows(i).Cells(2).Text
StartDate = CType(gvSelectScreen.Rows(i).FindControl("txtStartDate"), TextBox).Text
EndDate = gvSelectScreen.Rows(i).Cells(5).Text
Dim connStr As String = ConfigurationManager.ConnectionStrings("MainConnectionString").ConnectionString
Dim myCon As New SqlConnection(connStr)
Dim cmd As New SqlCommand("usp_ParametersFromGrid")
Dim dt As New DataTable
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@ContractNumber", SqlDbType.VarChar, 22).Value = ContractNumber.ToString()
cmd.Parameters.Add("@ClientProgramNumber", SqlDbType.VarChar, 22).Value = ClientProgramNumber.ToString()
cmd.Parameters.Add("@ClientProgramName", SqlDbType.VarChar, 100).Value = ClientProgramName.ToString()
cmd.Parameters.Add("@StartDate", SqlDbType.VarChar, 20).Value = StartDate.ToString()
cmd.Parameters.Add("@EndDate", SqlDbType.VarChar, 20).Value = EndDate.ToString()
cmd.Parameters.Add("@RequestID", SqlDbType.VarChar, 50).Value = RequestID.ToString()
cmd.Connection = myCon
myCon.Open()
cmd.ExecuteNonQuery()
myCon.Close()
End If

Now above the submit button as i said, there are few checkboxes and they are checked by default...how would i save the selected item (in the gridview and the checked checkbox values in the same row in the database(sql server)

View 5 Replies

DataSource Controls :: Save An Edit In A Gridview?

May 1, 2010

I get this while trying to save an edit in a Gridview. I removed the @albumUID whivh it automaticlly gerneated when a new record is enteredinto the database. BanUID is the only other uniqueidentifier but in this table it is not set to auto generate,I get the same response if I make a Detialviews and unsert.Here's the code

<asp:SqlDataSource ID="SqlDSAddAlbum" runat="server"
ConnectionString="<%&#36; ConnectionStrings:MyCDsConnectionStringHome %>"
DeleteCommand="DELETE FROM [Album] WHERE [AlbumUID] = @AlbumUID"

[code]...

View 1 Replies

DataSource Controls :: Save Data Into Sql Database From Gridview

Mar 27, 2010

i'm new to programming and i'm doing a project of ana e-store, i have a data gridview that brings data from a data base and it have to more templeate files one a textbox and the other one is a label. and i have a button outside the grivdview. what i need that when i press on this button it will take the values from the grid view and insert them into a new sql table.

[Code]....

and here is the VB code that i'm trying to use with no luck : [Code]....

View 7 Replies

Forms Data Controls :: Gridview Showing Values From Two Tables Accommodation And Pic (left Join On Accommodation)

Nov 19, 2010

I have a gridview showing values from two tables accommodation and pic (left join on accommodation). If there is no pic uploaded I want to display the row without the pic. So in the gridview I first check to see if the picid is null, if it is i don't render any 'a href' code , if it's isn't i do.

The problem that i'm having is that instead of the image showing up in the gridview itemtemplate i get
','_blank','toolbar=no,menubar=no'))" >

Here is my .aspx code

SelectCommand="SELECT pic.picid, aspnet_Users.Username, accommodation.location, accommodation.type,accommodation.description, convert(varchar,accommodation.createdate,101) as createdate

View 2 Replies

ADO.NET :: Bind Selected Values From Two Tables To Gridview Data Source

Mar 9, 2011

how to bind selected values from two tables to gridview data source, that two tables are from two databases. i created a view by using these two.But error is getting with this query,that is invalid object derivdtbl_1.Expr1. how to fix this?

SELECT dbo.Station_Channel.St_id, dbo.Station_Channel.lid, dbo.Station_Channel.Edit, dbo.Station_Channel.lChannelName, dbo.Station_Channel.lShort, dbo.Station_Channel.lPosition, dbo.Station_Channel.lTransformData, dbo.Station_Channel.lUnits, dbo.Station_Channel.lDecimalPts,
dbo.Station_Channel.parameter, dbo.Station_Channel.function_value, derivdtbl_1.Expr1
FROM dbo.Station_Channel CROSS JOIN
(SELECT MAX(Fecha) AS Expr1 FROM MeteoStation.dbo.Datos) AS derivdtbl_1
WHERE (dbo.Station_Channel.Edit = 1)

View 2 Replies

DataSource Controls :: Make A Button For Save As Gridview Data Into Mdb Access File?

Jul 24, 2010

i have a gridview that show data from sql data source . how i can make a button for save as gridview data into mdb access file !?

View 6 Replies

Forms Data Controls :: GridView,calculate Value Based On Other Columns& Save To Datasource?

Nov 8, 2010

I had just started with Visual Studio 2008 + VB.net. I've now designed my tables, and basic gridview functions properly.Now I'm faced with the problem of having to calculate a value based on 2 - 3 columns/data in the gridview, display the result in an existing column in the same gridview, and saving the calculated value in the datasource.I had initially created the "Total" column as a textbox displaying a manually calculated amount that is saved in the datasource. Now, I want to change the field to auto-calculate based on 2 other columns.

View 4 Replies

SQL Server :: Save To Tables In One Save Command?

Nov 18, 2010

I want to save two table in one transaction.

Ex.

table 1 : tblTransaction
Table 2 : tblTransDtls

the tblTransaction is my header and the tblTransDtls is the details about the header.

View 2 Replies

DataSource Controls :: How To Get First And Last Row Values From Gridview Or Dataset

Feb 25, 2010

MY CODING

string studentno = "select regno from stu_ref where batch='" + dropbatch.SelectedItem.ToString() + "'";
SqlDataAdapter dastudent = new SqlDataAdapter(studentno, cn1);
DataSet dsstudent = new DataSet();[code]....

form the above coding i will get all values form the table stu_ref of regno of student now i need to get the first and the last regno from the table

for eg TextBox1=103301
TextBox2=103378

the total no of student=78

View 5 Replies

Data Controls :: Display Data From Two Tables Into One Gridview Through Datasource

Feb 20, 2013

i have a problem in joining two tables the reason ismy first table persdata is having common field as pno (a single row in a particular person) and the second tables is also having pno(having muti entry for a person as this table is of qualification and a person may have more than 3 qualifications and their grading)sample persdata(table)pno name coy appt sample qual(table)pno qual grading recommendationi tried my best to do it and not able to proceedi want the output in a single row as in persdata to a gridview with all the qual combined in one coloumn and all the recommendations combined in one coloumn for a person.

View 1 Replies

ADO.NET :: Save Temporary Values In Gridview To Database

Sep 17, 2010

I have a code here,where it will store temporary data in a gridview from textbox where when the data is stored temporarily in gridview. Alternately,it will be linked to search the word in google. Now i want to save the values in the gridview to database. I m new to asp.net,seeking ideas from all. Here is my .aspx code:

[Code]....

And this is my .cs code:

[Code]....

View 8 Replies

DataSource Controls :: Gridview Updating The Old Values On RowUpdating?

May 11, 2010

I have a gridview that I'm trying to update the Date something is corrected in the database. When I am putting a new value in, it is updating, but it isn't updating the new value, just the old one that is already there. I cannot figure out why this is happening.

[Code]....

View 8 Replies

DataSource Controls :: Writing Multiple Gridview Checkbox Values To Database

Jun 11, 2010

I have a checkbox column in a Gridview that I would like to use to insert the value of one cell in the row into an access database. There will be a maximun of five cells allowed to be selected so there can be one value written to one field in the database up to the maximum of the five fields. The access database has five columns: Selection1 ,Selection2, Selection3 ,Selection4 and Selection5

When the checkbox is checked, the value of one cell (PliD) should be written to each field in the database. Ie: checkbox in row 1 should write PliD value to Selection1, checkbox in row 2 should write PliD value to Selection2, checkbox in row 3 should write PliD value to Selection3 and on depending on which checkbox has been checked. I am not sure how to get the value of the checkbox and write it into the corresponding fields in the database.

[Code]....

View 4 Replies

DataSource Controls :: Putting Multiple Select Values Into A Gridview From Using Data Reader

May 20, 2010

So far i've populated my grid view with my roomID. however using data reader I don't seem to be able to get more than one column to auto generate even though i'm now looking for three values : SELECT tt_roomEquip.roomID, tt_room.roomCapacity, tt_equip.equipTitle is my select bit of the sql, though it's only putting roomID into my grid view.

View 1 Replies

Save Into Multiple Tables?

Dec 8, 2010

I am new to ASP.net MVC. I am trying to save the data into Order and OrderDetail tables when I click on Save button from my MVC 'Create' page.

View 1 Replies

MVC :: Save Data To Two Associated Tables In A DB?

May 3, 2010

I have a little problem concerning the saving in two associated tables !

explanation :

i am using sql server 2008 and MVC 1.0

for the saving and edition i used the standard methode, wich is (using control and repository classes, and then "the add view" fonctionality).

in my case , i have a table A associated with another table B, this means that in the A i have other columns belonging to the table B, but when using the Add view, it doesn't add the ather column of the table B, even if in the sql server, in the design of the table i find these columns!

the code for grabbing data is:

[Code]....

and for the view here is the code generated:

[Code]....

the aim here is that i want to add for exampl an other property:
[Code]....

View 3 Replies

DataSource Controls :: Create XML With SQL Tables?

Jul 12, 2010

I have the following tables and fields in SQL:

[Code]....

I'd like to create an XML file(based on the above tables mentioned) which I'd like to bind to a treeview control, but I'm not sure how to do that.

View 2 Replies

DataSource Controls :: How To Get Data From Two Tables In Linq

Apr 28, 2010

How to get data from two tables through linq .1 ) productsDetails 2) productsImages to bind further listview.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved