|
-
February 23rd, 2009, 12:18 AM
#1
sqldata source Insert
I have the following code which is to get the data a user enters in a web form and insert it into the database.
Code:
... <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:jordanvalleybrConnectionString %>"
InsertCommand="INSERT INTO Player_Info(Player_FName, Player_LName, Address, City, State, Zip,
Parent_FName, Parent_LName, Parent_Phone, Email, Emergency_FName,
Emergency_LName, Emergency_Phone, Doctor_Name, Doctor_Phone)
VALUES (@playerFirstName,@playerLastName,@address,@city,@state,@zip,@parentFirstName,@parentLastName,@parentPhone,
@email,@emergencyFirstName,@emergencyLastName,@emergencyPhone,@doctorName,@doctorPhone)"
SelectCommand="SELECT * FROM [Player_Info]">
<InsertParameters>
<asp:FormParameter Name="playerFirstName" FormField="playerFirstName" />
<asp:FormParameter Name="playerLastName" FormField="playerLastName" />
<asp:FormParameter Name="address" FormField="TBaddress" />
<asp:FormParameter Name="city" FormField="TBCity" />
<asp:FormParameter Name="state" FormField="TBstate" />
<asp:FormParameter Name="zip" FormField="TBZip" />
<asp:FormParameter Name="parentFirstName" FormField="TBparentFirstName" />
<asp:FormParameter Name="parentLastName" FormField="TBparentLastName" />
<asp:FormParameter Name="parentPhone" FormField="TBParentPhone" />
<asp:FormParameter Name="email" FormField="TBEmail2" />
<asp:FormParameter Name="emergencyFirstName" FormField="TBcontactFirstName" />
<asp:FormParameter Name="emergencyLastName" FormField="TBContactLastName" />
<asp:FormParameter Name="emergencyPhone" FormField="TBContactPhone" />
<asp:FormParameter Name="doctorName" FormField="TBDoctorName" />
<asp:FormParameter Name="doctorPhone" FormField="TBDoctorPhone" />
</InsertParameters>
</asp:SqlDataSource>
when i enter data into every field on the form and run the insert() method I get the following error
Cannot insert the value NULL into column 'Player_FName', table 'jordanvalleybr.dbo.Player_Info'; column does not allow nulls. INSERT fails.
The statement has been terminated.
i have verified the ID of the text boxes are correct and they are not null..
it just seems to not be getting the data from the text box of the form.
Can you see if I am doing something wrong in the above code?
Thanks
Last edited by maitopoika; February 23rd, 2009 at 12:20 AM.
-
February 24th, 2009, 07:14 AM
#2
Re: sqldata source Insert
pls check whether u hav passed values to Player_FName. since it is a mandatory field, u hav to pass values.. only then the insert will b successful...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|