2 Replies - 2734 Views - Last Post: 26 March 2013 - 09:07 AM Rate Topic: -----

#1 moc007  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-May 10

Reading a data from another table: asp.net-C#

Posted 24 March 2013 - 02:39 AM

I need hints. I created two tables in the database, and each table has a column called number of quantity. I formed the number of quantity into text, so the user can enter the number of quantity. I did looping through the first table and showed the result of the whole table in a grid-view by clicking the button for looping. All i need to know is, how to insert or add the number of quantity, that the user enters via a button in another table, so i can find it checked in the table's record.

Thanks,

Is This A Good Question/Topic? 0
  • +

Replies To: Reading a data from another table: asp.net-C#

#2 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 296
  • View blog
  • Posts: 1,537
  • Joined: 07-April 08

Re: Reading a data from another table: asp.net-C#

Posted 25 March 2013 - 07:28 AM

So If I get what your saying correctly you are:

1) Storing the same data in 2 different tables
2) Gathering the data from Table1 and showing it in a gridview for edit by the end user
3) When the end user edits the data and clicks a button you want the values to then be stored in the second table
4) You are unsure how to insert the data into the second table upon button click.

Did I miss the mark on this one?

So if I'm right you will use a SQL INSERT statement. Since I do not know anything at all about what you've done or how your tables/application work I can only give you the generic syntax that you can then go out and use:


Private Sub Button1_Click(ByVal sender as Object, ByVal e as EventArgs) Handles Button1.click

    Dim sqlcon as new SqlConnection("<Connection String>")
    Dim sqlcom as new SqlCommand("INSERT INTO <Table>(<Columns>)VALUES(<Value List that Matches up to Column List>)",sqlcon)

    sqlcon.Open()
    sqlcom.ExecuteNonQuery()
    sqlcon.Close()
End Sub



That is extremely basic, and uses non-parameterized sql. I would suggest that you take that and run with it, and also remember to always use Parameterized Queries to prevent SQL Injection attacks

This post has been edited by rgfirefly24: 25 March 2013 - 07:29 AM

Was This Post Helpful? 1
  • +
  • -

#3 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1182
  • View blog
  • Posts: 1,677
  • Joined: 24-August 11

Re: Reading a data from another table: asp.net-C#

Posted 26 March 2013 - 09:07 AM

Why are you storing the same quantity number in two different tables? It sounds like you might have schema design issues.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1