Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6558057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:09:10+00:00 2026-05-25T13:09:10+00:00

I’m probably going about this the wrong way, but here goes: I am starting

  • 0

I’m probably going about this the wrong way, but here goes:

I am starting a club database in SQL server that includes ASP login functionality. I have been given all the members’ details in a spreadsheet and am trying to import every Club member into the database with their own login.

I have imported the spreadsheet to a table called Historical$ and have used Peter Kellner’s Membership Editor to set up the ASP Membership tables in my database. Works great!

Therefore I have all my club “members” as ASP Membership with their own login details but now want to put all their info (address, gender, etc) in a table that uses the UniqueIdentifier “UserId” from the ASP Membership tables as a foreign key.

In short, I want to import selected fields from my source table (Historical$) + the corresponding UserId from aspnet_Membership table into an empty table called “Club_Member”. I would prefer to use the structure that I already have in Club_member if possible.

Source table Historical$:

Mem_no  
Firstname  
Lastname  
email1  
...  

Source table aspnet_Membership:

...  
UserId  
...  
Email  
...

Target table Club_Member:

UserId  
Firstname  
Lastname  
Email  
...

I thought that the best way would be to use a SQLDataReader to select the fields with a table join, read each row in the results and insert into the new table, but having trouble working out the logic and syntax to insert into the new table.
C# Code:

protected void ButtonTransfer_Click(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection(connectionString);
        string strSQL1 = "Select Historical$.memnum, Historical$.first, Historical$.last, aspnet_Membership.UserId FROM aspnet_Membership INNER JOIN Historical$ ON aspnet_Membership.Email = Historical$.email1";
       con.Open();
         SqlCommand myCommand = new SqlCommand(strSQL1, con);

        SqlDataReader TransReader;
        TransReader= myCommand.ExecuteReader();
        while (TransReader.Read())
        {

            SqlDataSource1.Insert();
        }
    }  

ASP Code:

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:wtcConnectionString %>" 
        InsertCommand="INSERT INTO member(UserId, mem_number, mem_fname, mem_lname) VALUES (@UserId, @memnum, @first, @last)">
        <InsertParameters>
            <asp:Parameter Name="UserId" />
            <asp:Parameter Name="memnum" />
            <asp:Parameter Name="first" />
            <asp:Parameter Name="last" />
        </InsertParameters>
    </asp:SqlDataSource>        

I am getting the error: Cannot insert the value NULL into column ‘UserId’, table Club_Member; column does not allow nulls. INSERT fails.

First question is, Am I on the right track, or is there a better way?
Secondly, What might be causing the error?
I don’t mind if someone comes up with an easier way because this is supposed to be a “one-off” but I don’t get how to go about it! (BTW ASP.NET/C# knowledge limited, SQL knowledge very limited!)

Thanks, and sorry about the essay.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:09:10+00:00Added an answer on May 25, 2026 at 1:09 pm

    This should be done completely in SQL, using an INSERT statement, something like:

    INSERT Club_Member (UserID, Firstname, Lastname, Email....)
    SELECT m.UserID, c.FirstName, c.LastName, c.Email1
    FROM aspnet_membership m
    JOIN [Historical$] c on m.EMail = c.Email1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.