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

Insert Data into a table

Hi,

I am pretty new to HTML programming and I am stuck in one location at the moment. I created a web page where users can enter information and add it to a table in my SQL database. I am running into a problem where my table does not allow the insert of null rows and I don't know how to create the insert statement to skip the text boxes that does not have any information in them.

Can someone please help me?

Lawrence
Nov 22 '06 #1
5 4328
AricC
1,892 Expert 1GB
What is your table code? Are you using 'NOT NULL' when you create the table?
Nov 22 '06 #2
AricC,

These tables were already created and all I am doing is picking up from a previous programmer to try and make it easier to insert data into the table. I don't want to change the table settings, because there are still some programs that rely on that table.

If you want I can insert what I have done so far and you can let me know what I am doing wrong.

Thanks Aric
Nov 26 '06 #3
willakawill
1,646 1GB
AricC,

These tables were already created and all I am doing is picking up from a previous programmer to try and make it easier to insert data into the table. I don't want to change the table settings, because there are still some programs that rely on that table.

If you want I can insert what I have done so far and you can let me know what I am doing wrong.

Thanks Aric
Hi Aric. Inserting what you have so far will be a great help. It may be that you just plan your insert to put 'N/A' into the fields that you have no data for.
Nov 26 '06 #4
Ok,

This is what I have at the moment:

SQL query:

INSERT INTO PSD (CustomerId, CheckNumber, ItemId, FrankingCharge, ServiceCharge, Name, AccountYear, LastModified, DateCreated, ServiceYear, FrankingYear, ItemPrice, Quantity, CheckTotal) VALUES (@CustomerID, @CheckNumber, @ItemID, CAST(@FrankingCharge AS Money), CAST(@ServiceCharge AS Money), @Name, @AccountYear, @LastModified, @DateCreated, @ServiceYear, @FrankingYear, CAST(@ItemPrice AS Money), @Quantity, CAST(@CheckTotal AS Money))


On my HTML page I have a Dropdown list that lists my customers. I also have a table where they can enter information. At this stage it is a one line table which I want to make multiple lines. This is where I am stuck at the moment, because I can't enter Null's into the table and I need to figure out how to skip the text boxes or rows in the table that do not have any information in them.

Here is the HTML code:

Private Sub InsertRecord(ByVal sender As System.Object, ByVal e As System.EventArgs)
Insert.Insert()

End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
<!--

function TABLE1_onclick() {

}

// -->
</script>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
&nbsp;<asp:SqlDataSource ID="Insert" runat="server" ConnectionString="<%$ ConnectionStrings:InsertConnection %>"
InsertCommand="INSERT INTO PSD (CustomerId, CheckNumber, ItemId, FrankingCharge, ServiceCharge, Name, AccountYear, LastModified, DateCreated, ServiceYear, FrankingYear, ItemPrice, Quantity, CheckTotal) VALUES (@CustomerID, @CheckNumber, @ItemID, CAST(@FrankingCharge AS Money), CAST(@ServiceCharge AS Money), @Name, @AccountYear, @LastModified, @DateCreated, @ServiceYear, @FrankingYear, CAST(@ItemPrice AS Money), @Quantity, CAST(@CheckTotal AS Money))"
SelectCommand="SELECT PSD.* FROM [user].PSD"
UpdateCommand="UPDATE PSD SET CustomerId = @CustomerID, CheckNumber = @CheckNumber, ItemId = @ItemID, FrankingCharge = Convert(Money, @FrankingCharge), ServiceCharge = Convert(Money, @ServiceCharge), Name = @Name, AccountYear = @AccountYear, LastModified = @LastModified, DateCreated = @DateCreated, ServiceYear = @ServiceYear, FrankingYear = @FrankingYear, ItemPrice = Convert(Money, @ItemPrice), Quantity = @Quantity">
<UpdateParameters>
<asp:Parameter Name="CustomerID" />
<asp:Parameter Name="CheckNumber" />
<asp:Parameter Name="ItemID" />
<asp:Parameter Name="FrankingCharge" />
<asp:Parameter Name="ServiceCharge" />
<asp:Parameter Name="Name" />
<asp:Parameter Name="AccountYear" />
<asp:Parameter Name="LastModified" />
<asp:Parameter Name="DateCreated" />
<asp:Parameter Name="ServiceYear" />
<asp:Parameter Name="FrankingYear" />
<asp:Parameter Name="ItemPrice" />
<asp:Parameter Name="Quantity" />
</UpdateParameters>
<InsertParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CustomerID" PropertyName="SelectedValue" />
<asp:FormParameter Name="CheckNumber" formfield="CheckNumber"/>
<asp:FormParameter Name="ItemID" formfield="ItemDropdown"/>
<asp:FormParameter Name="FrankingCharge" Formfield="FrankingBox"/>
<asp:FormParameter Name="ServiceCharge" formfield="ServiceBox"/>
<asp:FormParameter Name="Name" formfield="CNameBox"/>
<asp:FormParameter Name="AccountYear" FormField="AccountBox" />
<asp:ControlParameter ControlID="TimeLabel" Name="LastModified" PropertyName="Text" />
<asp:ControlParameter ControlID="TimeLabel" Name="DateCreated" PropertyName="Text" />
<asp:FormParameter Name="ServiceYear" FormField="SyearBox"/>
<asp:FormParameter Name="FrankingYear" FormField="FyearBox"/>
<asp:FormParameter Name="ItemPrice" FormField="ItemPBox"/>
<asp:FormParameter Name="Quantity" FormField="QBox"/>
<asp:FormParameter Name="CheckTotal" FormField="CTotalBox"/>

</InsertParameters>
</asp:SqlDataSource>

I would greatly appreciate the help.

Thanks a bunch!!
Nov 27 '06 #5
I did not add the button Click:

<br />
<asp:Button
ID="Button1"
runat="server"
Text="Insert Record"
Width="181px"
onclick="InsertRecord"
/><br />

Thanks
Nov 27 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM,...
6
by: pk | last post by:
Sorry for the piece-by-piece nature of this post, I moved it from a dormant group to this one and it was 3 separate posts in the other group. Anyway... I'm trying to bulk insert a text file of...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
6
by: efgh | last post by:
I'm fairly confident in my knowledge of SQL but I'm stumped with regards with an Insert Into statement in Access 2003. I've got a 4 column table that I've simplified about as much as I can, no...
8
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with...
0
by: Christopher | last post by:
I AM GETTING A SYSTEM.DATA.SQLCLIENT.SQLEXCEPTION ERROR WHEN ATTEMPTING TO INSERT DATA INTO A SINGLE TABLE THROUGH A GRID //If this is due to a spelling error, i will //inflict a ritual...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
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:
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...
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
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.