Insert Into 2 database tables at the same time

Justice75
Justice75 used Ask the Experts™
on
Hi All,

I am using C#, FormView and SqlDataSource.  I have a form with several fields.  The form needs to  :

1)
a) Inserting the User_Name (from textbox), Password (fromtextbox) and UserType_Id (shared variable set in code behind) into Users table..
b) Retrieve the newly generated User_Id (autonumber) from Users table.

2.  Insert the User_Id from the previous table and insert it with the other values (Firstname, lastName, etc) into ANOTHER table Dealers.

Thank you

Can anyone help with this at all.  Any help would be greatly appreciated.

Jus
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
I'm not sure you can get the ID returned from the SQL Datasource.  You will have to insert the data into the table with code behind.  You can easily do this with Linq, here is an example:

var tbl = new UserTbl;
tbl.Username = txtUsername.Text;
tbl.Password = txtPassword.Text;
db.UserTbl.InsertOnSubmit(tbl);
var userId = tbl.UserId;
Commented:
Oh yes, it seems you can get the ID from a SQLDatasource by handling the Inserted event, see this MSDN article:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.inserted.aspx

Author

Commented:
Hi Halceyon:

I used the link that you listed below and got an error..  Is there something that I am doing wrong? However,, I haven't used a stored procedure so I modified that part.

Thanks,

Jus
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dealer_test1.aspx.cs" Inherits="dealer_test1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
  <div style="position:absolute; top:0px;left:600px;width:400px">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td width="50px" align="right">
                    <asp:TextBox ID="RecordCounter" runat="server" BorderStyle="None" 
                        Font-Bold="True" Font-Names="Tahoma" Font-Size="9pt" ForeColor="#AB1414" 
                        Width="50px"></asp:TextBox>
                </td>
                <td style="Font-Family:Tahoma; font-size:12px; font-weight:bold; color:#000000;" 
                    align="left">Total Records
                </td>
            </tr>
        </table>
    </div>   
      <div style="width:1024px; text-align: justify; overflow:hidden; padding-top:20px">                   
        <asp:GridView   
            ID="TopGrid" 
            runat="server" 
            AllowPaging="True" 
            AllowSorting="True" 
            AutoGenerateColumns="False" 
            CellPadding="2" 
            DataKeyNames="Dealer_Id" 
            DataSourceID="TopDS" 
            ForeColor="#333333" 
            GridLines="None" 
            Font-Names="Tahoma" 
            Font-Size="9pt" 
            Font-Bold="False" 
            Width="1024px" 
            PageSize="20" 
            FooterStyle-BackColor="White">
            <PagerSettings Position="TopAndBottom" />
            <FooterStyle/>
            <RowStyle BackColor="#FFFFFF" ForeColor="#333333" Font-Names="Tahoma" Font-Size="8pt" />
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField 
                            DataField="Dealer_Id" 
                            HeaderText="ID" 
                            InsertVisible="False" 
                            ReadOnly="True" 
                            SortExpression="Dealership_Id"
                            HeaderStyle-Width="3%" 
                            ItemStyle-Width="3%" 
                            FooterStyle-Width="3%" >
                        <FooterStyle Width="3%"></FooterStyle>
                        <HeaderStyle Width="3%" HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle Width="3%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField 
                            DataField="DealerContact_FirstName" 
                            HeaderText="First Name" 
                            SortExpression="DealerContact_FirstName" 
                            HeaderStyle-Width="15%" 
                            ItemStyle-Width="15%" 
                            FooterStyle-Width="15%">
                        <FooterStyle Width="15%"></FooterStyle>
                        <HeaderStyle Width="15%" HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle Width="15%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField 
                            DataField="DealerContact_LastName" 
                            HeaderText="Last Name" 
                            SortExpression="DealerContact_LastName" 
                            HeaderStyle-Width="15%" 
                            ItemStyle-Width="15%" 
                            FooterStyle-Width="15%">
                        <FooterStyle Width="15%"></FooterStyle>
                        <HeaderStyle Width="15%" HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle Width="15%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField 
                            DataField="Dealership_Name" 
                            HeaderText="Dealership" 
                            SortExpression="Dealership_Name" 
                            HeaderStyle-Width="15%" 
                            ItemStyle-Width="15%" 
                            FooterStyle-Width="15%">
                        <FooterStyle Width="15%"></FooterStyle>     
                        <HeaderStyle Width="15%" HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle Width="15%"></ItemStyle>
                    </asp:BoundField>
                   
                    <asp:BoundField 
                            DataField="DealerContact_Phone1" 
                            HeaderText="Phone" 
                            SortExpression="DealerContact_Phone1" 
                            HeaderStyle-Width="9%" 
                            ItemStyle-Width="9%" 
                            FooterStyle-Width="9%" >
                        <FooterStyle Width="9%"></FooterStyle>
                        <HeaderStyle Width="9%" HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle Width="9%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField 
                            DataField="DealerContact_Email1" 
                            HeaderText="Email" 
                            SortExpression="DealerContact_Email1" 
                            HeaderStyle-Width="28%" 
                            ItemStyle-Width="28%" 
                            FooterStyle-Width="28%">
                        <FooterStyle Width="28%"></FooterStyle>
                        <HeaderStyle Width="28%" HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle Width="28%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField 
                            DataField="Dealership_State" 
                            HeaderText="State" 
                            SortExpression="Dealership_State" 
                            HeaderStyle-Width="5%" 
                            ItemStyle-Width="5%" 
                            FooterStyle-Width="5%" >
                        <FooterStyle Width="5%"></FooterStyle>
                        <HeaderStyle Width="5%" HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle Width="5%"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField 
                            DataField="Dealership_ZipCode" 
                            HeaderText="Zip Code" 
                            SortExpression="Dealership_ZipCode" 
                            HeaderStyle-Width="6%" 
                            ItemStyle-Width="6%" 
                            FooterStyle-Width="6%" >
                        <FooterStyle Width="6%"></FooterStyle>
                        <HeaderStyle Width="6%" HorizontalAlign="Left"></HeaderStyle>
                        <ItemStyle Width="6%"></ItemStyle>
                    </asp:BoundField>
                </Columns>
                    <PagerStyle BackColor="White" ForeColor="Maroon" HorizontalAlign="Right" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="False" ForeColor="#333333"  />
                    <HeaderStyle BackColor="#AB1414" Font-Bold="True" ForeColor="White" Font-Names="Tahoma" Font-Size="9pt" HorizontalAlign="Left" />
                    <EditRowStyle BackColor="#999999" ForeColor="Black" />
                    <AlternatingRowStyle BackColor="Silver" ForeColor="Black" />
            </asp:GridView>                    

   <asp:SqlDataSource ID="TopDS" runat="server" 
             

        ConnectionString="<%$ ConnectionStrings:driveaway2day2 %>" 
         SelectCommand="SELECT CAR_Dealers.Dealer_Id, CAR_Dealers.DealerContact_FirstName, CAR_Dealers.DealerContact_LastName, CAR_Dealers.DealerContact_Phone1, CAR_Dealers.DealerContact_Email1, CAR_Dealership.Dealership_Name, CAR_Dealership.Dealership_State, CAR_Dealership.Dealership_ZipCode FROM CAR_Dealers INNER JOIN CAR_Dealership ON CAR_Dealers.Dealership_Id = CAR_Dealership.Dealership_Id"></asp:SqlDataSource>                                                     
        
</div>
<div>
        <asp:FormView 
            ID="FormView"
            OnItemInserting="FormView_ItemInserting" 
            runat="server" 
            CellPadding="0" 
            ForeColor="#333333"
            DataKeyNames="Dealer_Id" 
            DataSourceID="DetailDS" 
            AllowPaging="true" 
            Width="1024px" 
            BackColor="Black" 
            Font-Names="Tahoma" 
            Font-Size="8pt">
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <ItemTemplate>
            <table border="0" width="1024px">
                <tr>
                <td height="20px" colspan="4" style="padding-top:0px;">&nbsp; </td>
                </tr>
                <tr>
                <td colspan="4" style="padding-left:3px;height:20px; background-color:#E2DED6; font-family: Tahoma; font-size:12px; color:#000000; font-weight:bold; width:1024px;">Dealer Details</td>
                </tr>
                <tr>
                    <td>
                        <table width="900px">
                            <tr>
                                <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Dealer ID</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("Dealer_Id")%></td>
                                <td style="padding-top:5px;" width="100px">User ID</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("User_Id")%></td>   
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Referral Fee</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_ReferralFee")%></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                             <tr>                   
                                <td style="padding-top:5px; font-weight:bold;" width="100px">CONTACT</td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">First Name</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_FirstName")%></td>
                                <td style="padding-top:5px;" width="100px">Fax</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_Fax")%></td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Last Name</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_LastName")%></td>
                                <td style="padding-top:5px;" width="100px">Email 1</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_Email1")%></td>
                            </tr>
                             <tr>                   
                                <td style="padding-top:5px;" width="100px">Phone 1</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_Phone1")%></td>
                                <td style="padding-top:5px;" width="100px">Email 2</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_Email2")%></td>
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Phone 2</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_Phone2")%></td>                   
                                <td style="padding-top:5px;" width="100px">Email 3</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_Email3")%></td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Phone 3</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("DealerContact_Phone3")%></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                             <tr>                   
                                <td style="padding-top:5px;font-weight:bold;" width="100px">DEALERSHIP</td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Dealership</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Name")%></td>
                                <td style="padding-top:5px;" width="100px">City</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_City")%></td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Branch/Location</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_BranchName")%></td>
                                <td style="padding-top:5px;" width="100px">State</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_State")%></td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Address</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Address")%></td>
                                <td style="padding-top:5px;" width="100px">Zip Code</td>
                                <td style="padding-top:5px;" width="300px"><%# Eval("Dealership_ZipCode")%></td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px; font-weight:bold;" width="100px">CREDIT</td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">No Credit</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="DealerNoCreditCheckBox" 
                                        runat="server" Checked='<%# Bind("DealerNoCredit") %>' 
                                        Enabled="false" />
                                </td>  
                                <td style="padding-top:5px;" width="100px">Multiple Repo</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox1" 
                                        runat="server" Checked='<%# Bind("DealerRepoMultiple") %>' 
                                        Enabled="false" />
                                </td>                                                        
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Slow Credit</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox2" 
                                        runat="server" Checked='<%# Bind("DealerSlowCredit") %>' 
                                        Enabled="false" />
                                </td>
                                <td style="padding-top:5px;" width="100px"> Repo / Ban</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox3" 
                                        runat="server" Checked='<%# Bind("DealerRepoBan") %>' 
                                        Enabled="false" />
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Discharged Ban</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox4" 
                                        runat="server" Checked='<%# Bind("DealerBanDischarged") %>' 
                                        Enabled="false" />
                                </td>
                                <td style="padding-top:5px;" width="100px">Employed <12 Months</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox5" 
                                        runat="server" Checked='<%# Bind("DealerJob12") %>' 
                                        Enabled="false" />
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Recent Ban</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox6" 
                                        runat="server" Checked='<%# Bind("DealerBanRecent") %>' 
                                        Enabled="false" />
                                </td>
                                <td style="padding-top:5px;" width="100px">Employed <6 Months</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox8" 
                                        runat="server" Checked='<%# Bind("DealerJob6") %>' 
                                        Enabled="false" />
                                </td>                                
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Multiple Ban</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox7" 
                                        runat="server" Checked='<%# Bind("DealerBanMultiple") %>' 
                                        Enabled="false" />
                                </td>
                                <td style="padding-top:5px;" width="100px">Employed <3 Months</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox9" 
                                        runat="server" Checked='<%# Bind("DealerJob3") %>' 
                                        Enabled="false" />
                                </td>                                                       
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Paid Repo</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox10" 
                                        runat="server" Checked='<%# Bind("DealerRepoPaid") %>' 
                                        Enabled="false" />
                                </td>
                                <td style="padding-top:5px;" width="100px">DP Finance</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox11" 
                                        runat="server" Checked='<%# Bind("DealerDPFinance") %>' 
                                        Enabled="false" />
                                </td>                            
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Repo <12 Months</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox12" 
                                        runat="server" Checked='<%# Bind("DealerRepo6") %>' 
                                        Enabled="false" />
                                </td>
                                <td style="padding-top:5px;" width="100px">In-House Finance</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox13" 
                                        runat="server" Checked='<%# Bind("DealerInHouseFinance") %>' 
                                        Enabled="false" />
                                </td>                            
                            </tr>
                            <tr>
                             <td style="padding-top:5px;" width="100px">Recent Repo</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox14" 
                                        runat="server" Checked='<%# Bind("DealerRepoRecent") %>' 
                                        Enabled="false" />
                                </td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 

                            </tr>
                            <tr>
                                <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
                            </tr>
                        </tr>
                    </table>
                </td>
               
            <tr>
                 <td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;">&nbsp;</td>              
            </tr>
            <tr>
                 <td colspan="4" style="padding-top:5px;height:15px;">&nbsp;</td>               
            </tr>
            
            <tr>
                <td colspan="2" style="padding-top:5px;">
                    <asp:Button ID="btnEdit" runat="Server" CommandName="Edit" Text="Edit" Font-Names="Tahoma" Font-Size="10px" />
                    <asp:Button ID="btnInsert" runat="Server" CommandName="New" Text="New" Font-Names="tahoma" Font-Size="10px" />
                    <asp:Button ID="btnDelete" runat="Server" CommandName="btnDelete" OnCommand="Button1_Command" Text="Delete" OnClientClick="return confirm('Are you sure to Delete?');" Font-Size="10px" Font-Names="tahoma" />
                </td>
            </tr>
        </table>
     </ItemTemplate>
     
 <InsertItemTemplate>
             <table border="0" width="1024px" style="padding-top:0px;">
                <tr>
                    <td height="20px" colspan="4" style="padding-top:0px;">&nbsp; </td>
                </tr>
                <tr>
                <td colspan="4" style="padding-left:3px;height:20px; background-color:#E2DED6; font-family: Tahoma; font-size:12px; color:#000000; font-weight:bold; width:1024px;">Dealership Details</td>
                </tr>
                <tr>
                    <td>
                        <table width="900px">
                            <tr>
                                <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px; font-weight:bold;" width="100px">Register</td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">User Name</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox ID="TextBox1" 
                                        runat="server" 
                                        Text='<%# Bind("User_Name") %>' /></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Password</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox ID="TextBox3" 
                                        runat="server" 
                                        Text='<%# Bind("Password") %>' /></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Referral Fee</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox ID="DealerContact_ReferralFeeTextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_ReferralFee") %>' /></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                             <tr>                   
                                <td style="padding-top:5px; font-weight:bold;" width="100px">CONTACT</td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">First Name</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox 
                                        ID="TextBox11" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_FirstName") %>' /></td>
                                <td style="padding-top:5px;" width="100px">Fax</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox 
                                        ID="DealerContact_FaxTextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_Fax") %>' /></td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Last Name</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox 
                                        ID="DealerContact_LastNameTextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_LastName") %>' />
                               </td>
                                <td style="padding-top:5px;" width="100px">Email 1</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox 
                                        ID="DealerContact_Email1TextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_Email1") %>' />
                                </td>
                            </tr>
                             <tr>                   
                                <td style="padding-top:5px;" width="100px">Phone 1</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox ID="DealerContact_Phone1TextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_Phone1") %>' /></td>
                                <td style="padding-top:5px;" width="100px">Email 2</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox 
                                        ID="DealerContact_Email2TextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_Email2") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Phone 2</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox 
                                        ID="DealerContact_Phone2TextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_Phone2") %>' />
                                </td>                   
                                <td style="padding-top:5px;" width="100px">Email 3</td>
                                <td style="padding-top:5px;" width="300px">            
                                    <asp:TextBox 
                                        ID="DealerContact_Email3TextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_Email3") %>' />
                                </td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">Phone 3</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:TextBox 
                                        ID="DealerContact_Phone3TextBox" 
                                        runat="server" 
                                        Text='<%# Bind("DealerContact_Phone3") %>' />
                                </td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                             <tr>                   
                                <td style="padding-top:5px;font-weight:bold;" width="100px">DEALERSHIP</td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">State</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:DropDownList class="aclDetDD" 
                                        ID="myDropDownList" 
                                        runat="server" 
                                        AutoPostBack="True" 
                                        DataSourceID="SqlDataSource1" 
                                        DataTextField="Dealership_State" 
                                        DataValueField="Dealership_State"> 
                                        
                                        <asp:ListItem 
                                            Value="">Select a State...
                                            
                                        </asp:ListItem>  
                                    </asp:DropDownList>  
	                                    <asp:SqlDataSource 
                                            ID="SqlDataSource1" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:driveaway2day2 %>" 
                                            SelectCommand="SELECT DISTINCT [Dealership_State] FROM [CAR_Dealership]">
                                        </asp:SqlDataSource>                        
                                </td>
                                 <td style="padding-top:5px;" width="100px">Dealership</td>
                                <td style="padding-top:5px;" width="300px">
                                    <asp:DropDownList class="aclDetDD" ID="DropDownList1" runat="server"        
                                        DataSourceID="SqlDataSource2"        
                                        DataValueField="Dealership_Id"                                          
                                        DataTextField="Dealership_Name">     
                                        <asp:ListItem 
                                            Value="">Select a Dealership...
                                        </asp:ListItem>        
                                     </asp:DropDownList> 
                                        <asp:SqlDataSource 
                                            ID="SqlDataSource2" 
                                            runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:driveaway2day2 %>" 
                                            SelectCommand="SELECT [Dealership_Id], [Dealership_State], [Dealership_Name] FROM [CAR_Dealership] WHERE ([Dealership_State] = @Dealership_State)">
                                        
                                        <SelectParameters>
                                            <asp:ControlParameter 
                                                ControlID="myDropDownList" 
                                                Name="Dealership_State" 
                                                PropertyName="SelectedValue" 
                                                Type="String" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                    </td>
                            </tr>
                            
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px; font-weight:bold;" width="100px">CREDIT</td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 
                            </tr>
                            <tr>                   
                                <td style="padding-top:5px;" width="100px">No Credit</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox0" 
                                        runat="server" Checked='<%# Bind("DealerNoCredit") %> '/>
                                </td>  
                                <td style="padding-top:5px;" width="100px">Multiple Repo</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox1" 
                                        runat="server" Checked='<%# Bind("DealerRepoMultiple") %>' />
                                </td>                                                        
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Slow Credit</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox2" 
                                        runat="server" Checked='<%# Bind("DealerSlowCredit") %>'  />
                                </td>
                                <td style="padding-top:5px;" width="100px"> Repo / Ban</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox3" 
                                        runat="server" Checked='<%# Bind("DealerRepoBan") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Discharged Ban</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox4" 
                                        runat="server" Checked='<%# Bind("DealerBanDischarged") %>' />
                                </td>
                                <td style="padding-top:5px;" width="100px">Employed <12 Months</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox5" 
                                        runat="server" Checked='<%# Bind("DealerJob12") %>' />
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Recent Ban</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox6" 
                                        runat="server" Checked='<%# Bind("DealerBanRecent") %>'/>
                                </td>
                                <td style="padding-top:5px;" width="100px">Employed <6 Months</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox8" 
                                        runat="server" Checked='<%# Bind("DealerJob6") %>' />
                                </td>                                
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Multiple Ban</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox7" 
                                        runat="server" Checked='<%# Bind("DealerBanMultiple") %>' />
                                </td>
                                <td style="padding-top:5px;" width="100px">Employed <3 Months</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox9" 
                                        runat="server" Checked='<%# Bind("DealerJob3") %>' />
                                </td>                                                       
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Paid Repo</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox10" 
                                        runat="server" Checked='<%# Bind("DealerRepoPaid") %>' />
                                </td>
                                <td style="padding-top:5px;" width="100px">DP Finance</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox11" 
                                        runat="server" Checked='<%# Bind("DealerDPFinance") %>' />
                                </td>                            
                            </tr>
                            <tr>
                                <td style="padding-top:5px;" width="100px">Repo <12 Months</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox12" 
                                        runat="server" Checked='<%# Bind("DealerRepo6") %>' />
                                </td>
                                <td style="padding-top:5px;" width="100px">In-House Finance</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox13" 
                                        runat="server" Checked='<%# Bind("DealerInHouseFinance") %>' />
                                </td>                            
                            </tr>
                            <tr>
                             <td style="padding-top:5px;" width="100px">Recent Repo</td>
                                <td style="padding-top:5px;" width="300px"> 
                                    <asp:CheckBox ID="CheckBox14" 
                                        runat="server" Checked='<%# Bind("DealerRepoRecent") %>' />
                                </td>
                                <td style="padding-top:5px;" width="100px"></td>
                                <td style="padding-top:5px;" width="300px"></td> 

                            </tr>
                            <tr>
                                <td colspan="4" style="padding-top:5px;height:5px;">&nbsp;</td>        
                            </tr>
                        </tr>
                    </table>
                </td>
               
            <tr>
                 <td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;">&nbsp;</td>               
            </tr>
            <tr>
                 <td colspan="4" style="padding-top:5px;height:15px;">&nbsp;</td>                
            </tr>              
            <tr>
                <td colspan="2" style="padding-top:5px;">
                     <asp:Button ID="btnSave" OnClick="Button_Clicked" runat="Server" CommandName="insert" Text="Insert" Font-Names="tahoma" Font-Size="10px" />
                        <asp:Button ID="Button1" runat="Server" CommandName="Cancel" Text="Cancel" CausesValidation="False" Font-Names="tahoma" Font-Size="10px" />

                </td>
            </tr>      
        </table>
     </InsertItemTemplate>       
    </asp:FormView>   
    
    
    
<asp:SqlDataSource ID="DetailDS" runat="server" OnInserting="SqlDataSource1_Inserting" 
        ConnectionString="<%$ ConnectionStrings:driveaway2day2 %>" 
        
        SelectCommand="SELECT CAR_Dealers.Dealer_Id, CAR_Dealers.Dealership_Id, CAR_Dealers.User_Id, CAR_Dealers.DealerContact_ReferralFee, CAR_Dealers.DealerContact_FirstName, CAR_Dealers.DealerContact_Phone2, CAR_Dealers.DealerContact_LastName, CAR_Dealers.DealerContact_Phone1, CAR_Dealers.DealerContact_Phone3, CAR_Dealers.DealerContact_Fax, CAR_Dealers.DealerContact_Email1, CAR_Dealers.DealerContact_Email2, CAR_Dealers.DealerContact_Email3, CAR_Dealers.DealerNoCredit, CAR_Dealers.DealerSlowCredit, CAR_Dealers.DealerBanDischarged, CAR_Dealers.DealerBanMultiple, CAR_Dealers.DealerBanRecent, CAR_Dealers.DealerRepoPaid, CAR_Dealers.DealerRepo6, CAR_Dealers.DealerRepoRecent, CAR_Dealers.DealerRepoMultiple, CAR_Dealers.DealerRepoBan, CAR_Dealers.DealerJob12, CAR_Dealers.DealerJob6, CAR_Dealers.DealerJob3, CAR_Dealers.DealerDPFinance, CAR_Dealers.DealerInHouseFinance, CAR_Dealership.Dealership_Name, CAR_Dealership.Dealership_BranchName, CAR_Dealership.Dealership_Address, CAR_Dealership.Dealership_City, CAR_Dealership.Dealership_State, CAR_Dealership.Dealership_ZipCode FROM CAR_Dealers INNER JOIN CAR_Dealership ON CAR_Dealers.Dealership_Id = CAR_Dealership.Dealership_Id WHERE (CAR_Dealers.Dealer_Id = @Dealer_Id)"      
        DeleteCommand="DELETE FROM [CAR_Dealers] WHERE [Dealer_Id] = @Dealer_Id" 
        
       InsertCommand="INSERT INTO [CAR_Dealers] ([Dealership_Id],[User_Id],[DealerContact_ReferralFee], [DealerContact_FirstName],[DealerContact_LastName],[DealerContact_Phone1],[DealerContact_Phone2],[DealerContact_Phone3],[DealerContact_Fax],[DealerContact_Email1],[DealerContact_Email2],[DealerContact_Email3],[DealerNoCredit],[DealerSlowCredit],[DealerBanDischarged],[DealerBanMultiple],[DealerBanRecent],[DealerRepoPaid],[DealerRepo6],[DealerRepoRecent],[DealerRepoMultiple],[DealerRepoBan],[DealerJob12],[DealerJob6],[DealerJob3],[DealerDPFinance],[DealerInHouseFinance] ) VALUES (@Dealership_Id,@User_Id,@DealerContact_ReferralFee,@DealerContact_FirstName,@DealerContact_LastName,@DealerContact_Phone1,@DealerContact_Phone2,@DealerContact_Phone3,@DealerContact_Fax,@DealerContact_Email1,@DealerContact_Email2,@DealerContact_Email3,@DealerNoCredit,@DealerSlowCredit,@DealerBanDischarged,@DealerBanMultiple,@DealerBanRecent,@DealerRepoPaid,@DealerRepo6,@DealerRepoRecent,@DealerRepoMultiple,@DealerRepoBan,@DealerJob12,@DealerJob6,@DealerJob3,@DealerDPFinance,@DealerInHouseFinance); INSERT INTO [CAR_Users] ([UserType_Id],[User_Name],[Password]) VALUES (@UserType_Id,@User_Name,@Password);         SELECT @PK_New = @@IDENTITY
        RETURN (1) " >
    
    <SelectParameters>
        <asp:ControlParameter ControlID="TopGrid" Name="Dealer_Id" 
            PropertyName="SelectedValue" Type="Int32" />
    </SelectParameters>      
    
    <DeleteParameters>
        <asp:Parameter Name="Dealership_Id" Type="Int32" />
    </DeleteParameters>
    
    <InsertParameters>
    
        <asp:Parameter Name="UserType_Id" Type="Int32" />                                  
        <asp:Parameter Name="User_Name" Type="String" />
        <asp:Parameter Name="Password" Type="String" />
        <asp:Parameter Direction="Output" Name="PK_New" Type="Int32" />   

        <asp:Parameter Name="Dealership_Id" Type="Int32" />
        <asp:Parameter Name="User_Id" Type="Int32" />                                  
        <asp:Parameter Name="DealerContact_ReferralFee" Type="String" />
        <asp:Parameter Name="DealerContact_FirstName" Type="String" />
        <asp:Parameter Name="DealerContact_LastName" Type="String" />
        <asp:Parameter Name="DealerContact_Phone1" Type="String" />
        <asp:Parameter Name="DealerContact_Phone2" Type="String" />
        <asp:Parameter Name="DealerContact_Phone3" Type="String" />
        <asp:Parameter Name="DealerContact_Fax" Type="String" />
        <asp:Parameter Name="DealerContact_Email1" Type="String" />
        <asp:Parameter Name="DealerContact_Email2" Type="String" />
        <asp:Parameter Name="DealerContact_Email3" Type="String" />
        
        <asp:Parameter Name="DealerNoCredit" Type="Boolean" />
        <asp:Parameter Name="DealerSlowCredit" Type="Boolean" />
        <asp:Parameter Name="DealerBanDischarged" Type="Boolean" />
        <asp:Parameter Name="DealerBanMultiple" Type="Boolean" />
        <asp:Parameter Name="DealerBanRecent" Type="Boolean" />
        <asp:Parameter Name="DealerRepoPaid" Type="Boolean" />
        <asp:Parameter Name="DealerRepo6" Type="Boolean" />
        <asp:Parameter Name="DealerRepoRecent" Type="Boolean" />
        <asp:Parameter Name="DealerRepoMultiple" Type="Boolean" />
        <asp:Parameter Name="DealerRepoBan" Type="Boolean" />
        <asp:Parameter Name="DealerJob12" Type="Boolean" />
        <asp:Parameter Name="DealerJob6" Type="Boolean" />
        <asp:Parameter Name="DealerJob3" Type="Boolean" />
        <asp:Parameter Name="DealerDPFinance" Type="Boolean" />
        <asp:Parameter Name="DealerInHouseFinance" Type="Boolean" />
        
        
    </InsertParameters>
    </asp:SqlDataSource>

</div>             
                                        











    
    
    
    </div>
    </form>
</body>
</html>

Open in new window

dealer-test1.aspx.cs
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Commented:
Hi Justice75,

Can you post the error details please...

Author

Commented:
Hi,

Thanks for your help.  Thats  the problem also.  No errors come up.  

Author

Commented:
Sorry, The error is below:

 Object must implement IConvertible.
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.InvalidCastException: Object must implement IConvertible.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Top Expert 2013

Commented:
This is a bit similar see if it helps:
 http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24550303.html

1. Stored proc is a better option and the code in above link does use that. If it seems complicated no worry we we see it here.

2.Other option could be using SqlDataSource3 that you had earlier i.e. seperate for Users table.
Then do some trick like before using Inserting / Inserted events.

But might need sometime to put a sample together for either of those options. May be sometime later today.
In the mean while can you post your code as a files one again.

Author

Commented:
Guru Sami:

I am of course willing to use a stored procedure.  The problem is that I have never used or created one.  Thank you for following me on these issues.  
dealer-test1.txt
dealer-test1.aspx.cs

Author

Commented:
So the stored procedure is great but I need to know how if that's ok but I will follow closely.

Jus
Top Expert 2013

Commented:
what is the type of User_Id in the table?
I mean is it autogenerated Identity or uniqeIdentifier autogenerated?

Author

Commented:
In the users table it is uniqeIdentifier autogenerated but in the dealers table it is an int32.  

Author

Commented:
Guru Sami.. I have a question.. Do you think that its best to use the .net membership (create user wizzard) or is the older users table structure fine?  
Top Expert 2013

Commented:
looks you did not set Foreign Key relations between two tables?
Is that what you want...don't think so from what you are trying to do.
If that User_Id in dealers table is referring the same user in User_Table then
1: Set the type in dealers table as uniqueidentifier as well and then create a foreign key relation with User_Id table.

Check sample here on how two tables are related using FK:
http://www.asp.net/learn/security/tutorial-08-vb.aspx
Top Expert 2013
Commented:
---> Do you think that its best to use the .net membership (create user wizzard) or is the older users table structure fine?
Depends...on what kind of application you are creating. Need some more information.
Secondly, since you have asked that question I was wondering you are creating user and collecting all info in one step can you split that into two.

You can use asp.net membership and createuser wizard to do that and the link provided earlier uses asp.net membership but there user is created separately and info is collected later and not at the time when user is created.

Author

Commented:
Its collecting the information at the same time.  There are other types of users also.  Do you have a skype acct or an email (only to tell you what it is)? I dont feel comfortable having it in the knowledge base.. Ist here a way to create the user and insert the information in the same form?

Jus
Top Expert 2013

Commented:
no problem.
Oh...EE don't have option to send mail to another user??
Anyways... go to my profile page where I have my email.

Author

Commented:
Ok I sent you what it is to your gmail.  I also looked at the tutorial that you provided.  I have a quick question.  Is it possible to add the tables, etc of the membership database. to an existing db?  My ISP charges for the amount of dbs that we use.  If not no sweat but I also thought that it would be more accessible if everything was in 1 db structure.

Jus

Author

Commented:
Let me know if you need more information (specifics)...  I'm ready to get started.

Jus
Top Expert 2013
Commented:
Got that.

--->  Is it possible to add the tables, etc of the membership database. to an existing db?

yes that is perfectly possible. For that you use aspnet_regsql.exe utility.
http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx
http://www.asp.net/learn/security/tutorial-04-vb.aspx

In you code above I see you have the following columns for your users table:

  <asp:Parameter Name="UserType_Id" Type="Int32" />                                  
        <asp:Parameter Name="User_Name" Type="String" />
        <asp:Parameter Name="Password" Type="String" />
        <asp:Parameter Direction="Output" Name="PK_New" Type="Int32" />  

What is UserType_Id? and why is it in the users_table?
--->Why am I asking ?
If you plan to use built-in asp.net membership provider you are stuck on the Users table schema they have provided. It is not easy / recommended to modify those tables. So if you just want to use username,password then you are good to go but if you want UserType_Id in your users table, asp.net membership is not what you want.
If you can provide here or email me your database schema or screenshots of your Users and dealership tables it would be enough to provide you with some code.
Unfortunately no IM.

Author

Commented:
there are 4 different types of users with 4 different permissions included users not logged in..

Author

Commented:
I am willing to abandon the usetype id as it goes with the structure of the membership that I am using now.  Doesnt asp.net membership have permissions and roles  built in right?

Jus
Top Expert 2013

Commented:
Yes, you can use asp.net roles as well.
Here is one more sample that creates a user, takes additional information and adds the user to roles.
http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx

Note: That sample uses asp.net built-in profiles which I will not suggest you to use but the concept used will be similar to that when using asp.net membership and roles.

One more question: Who is going to create the user i.e. registration will be done by some admin or the users themselves?
If latter ...Are they allowed to select their permissions/roles themselves?

Author

Commented:
Hi Guru Sami,

Thank you for your follow up again.  Two (2) of the user group members (dealers and customers) will be created through registration and company admin.  The company group members will be created only by myself (or another company admin - in the future).

Jus
Top Expert 2013
Commented:
----> Two (2) of the user group members (dealers and customers) will be created through registration and company admin.
I did not get that exactly.

Did the last link give any better idea.
One more thing I would like to point out is if it is just a registration form you can simply create Registration UI instead of going with the FormView which shouldn't be difficult or CreateUserWizard (which goes with membership providers).

One more example which might fit your scenario:http://aspnet.4guysfromrolla.com/articles/070506-1.aspx

Author

Commented:
It gave me a better idea of membership as a whole.. Thank you so much.  The questions that I still have are:

1) how do I get an id back when we are inserting into more that one table still.. Lets say that if it wasn't for a member and was for inventory or something.  I still dont know how to get an id back and insert it into another table

2) I didn't see from the other tutorial how to add the membership tables to an existing SQL database..

Thanks,

Jus
Top Expert 2013

Commented:
1: When using SqlDataSource you can add an output parameter like in this example:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.inserting.aspx
See it shows you how to user stored procedure as well.

2: as said earlier you need to run aspnet_regsql.exe
http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx
http://www.asp.net/learn/security/tutorial-04-vb.aspx

Author

Commented:
With the output parameter ... I tried that example but the stored procedure lost me...
Top Expert 2013
Commented:
without stored procedure you simply do an explicit query like below:
Once user is inserted make another select call to the DB.

using System.Data;
using System.Data.SqlClient;


SqlConnection conn = new SqlConnection("YourDataBaseConnectionString");
string selectQuery = "Select UserId from UsersTable where Username=@Username";
SqlCommand cmd = new SqlCommand(selectQuery, conn);
cmd.Parameters.AddWithValue("@Username",txtUsername.Text);
Guid userid = (Guid)cmd.ExecuteScalar(); //Guid because it is uniqueidentifier

Not sure we are heading in right direction of your initial problem or drifted away.

Author

Commented:
I think that we drifted a bit.  But we are back on track.  However, I learned a great deal in the drift..  I need to know how to create the stored procedure and I think that I need to just close this question and come back to the drawing board because now you have convinced me to use the .net membership tables ;). I am scratching the db that I have now and doing things a bit differently.   Thank you for EVERYTHING.  

If it is ok with you, I can email you when I come back with this registration.  I am going to take the next two days to read on the .net membership.

Jus

Author

Commented:
Your help has truly been invaluable.  Points are most certainly not enough for the help that you offer but its all that I have in this environment.  Thank you knidly.
Top Expert 2013

Commented:
--> If it is ok with you, I can email you when I come back with this registration.
yeah but preferably post your question here and email me the link. That way your question gets attention from other experts as well.

Author

Commented:
Awesome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial