Member_Record table returns error

Discussion in 'Databases' started by ycwliberiao, Jun 26, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi Wisemax; hi guys,

    I having a rather confused and I need your help in providing me the simplest most explanatory way I can handle this.

    I have one website and one database at discountasp.net. I have deployed the asp.net membership objects on that database and I have also created a table called Member_Record on that same database to store details of members joining my organization online.

    Now; my asp.net membership objects on the database are working; people can sign up, sign in, etc and it is working, but when someone fills in the other form which data is to go to the Member_Record table, it returns error. That is not working.

    Now here is the connectionstring in the web.config file:

    <connectionStrings>
    <clear/>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data Source=tcp:sql2k802.discountasp.net;Integrated Security=false;Initial Catalog=SQL2008_639451_ycwliberiadb;User ID=SQL2008_639451_ycwliberiadb_user;Password=**********" providerName="System.Data.SqlClient"/>
    <remove name="alieConnection"/>
    <add name="alieConnection" connectionString="Data Source=tcp:sql2k802.discountasp.net;Integrated Security=false;Initial Catalog=SQL2008_639451_ycwliberiadb;User ID=SQL2008_639451_ycwliberiadb_user;Password=**********" providerName="System.Data.SqlClient"/>
    </connectionStrings>

    The LocalSqlServer is meant for the asp.net membership objects and the alieConnection is meant for the Member_Record table.

    Now to connect my onlineRegister.aspx to the database, below is the code I wrote in my onlineRegister.aspx.cs file. I have not written anything to handle or catch error:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Data;
    public partial class onlineRegister : System.Web.UI.Page
    {

    protected void SubmitButton_Click(object sender, EventArgs e)
    {


    string Applicant_Name = AppNameTextBox.Text;
    string Applicant_Age = AgeTextBox.Text;
    string Applicant_Email = EmailTextBox.Text;
    string Applicant_Address = AppAddyTextBox.Text;
    string Applicant_Contact = ContactTextBox.Text;
    string School_or_University = SchoolTextBox.Text;
    string Major_Minor = MajorTextBox.Text;
    string Grade_Year = GradeTextBox.Text;
    string School_Location = SchLocationTextBox.Text;
    string Membership_Type = membershipDropDownList.SelectedItem.ToString();
    string Parent_Name = ParentNameTextBox.Text;
    string Parent_Adress = ParentAddyTextBox.Text;

    using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["alieConnection"].ConnectionString))
    {


    SqlCommand alieCommand = new SqlCommand("insert into Member_Record(Applicant_Name, Applicant_Age, Applicant_Email, Applicant_Address, Applicant_Contact,School_or_University,Grade_Year,Major_Minor,School_Location,Membership_Type,Parent_Name,Parent_Adress)values(@Applicant_Name, @Applicant_Age, @Applicant_Email, @Applicant_Address, @Applicant_Contact, @School_or_University, @Grade_Year, @Major_Minor, @School_Location, @Membership_Type, @Parent_Name, @Parent_Adress)", myConnection);
    alieCommand.Parameters.Add(new SqlParameter("@Applicant_Name", Applicant_Name));
    alieCommand.Parameters.Add(new SqlParameter("@Applicant_Age", Applicant_Age));
    alieCommand.Parameters.Add(new SqlParameter("@Applicant_Email", Applicant_Email));
    alieCommand.Parameters.Add(new SqlParameter("@Applicant_Address", Applicant_Address));
    alieCommand.Parameters.Add(new SqlParameter("@Applicant_Contact", Applicant_Contact));
    alieCommand.Parameters.Add(new SqlParameter("@School_or_University", School_or_University));
    alieCommand.Parameters.Add(new SqlParameter("@Grade_Year", Grade_Year));
    alieCommand.Parameters.Add(new SqlParameter("@Major_Minor", Major_Minor));
    alieCommand.Parameters.Add(new SqlParameter("@School_Location", School_Location));
    alieCommand.Parameters.Add(new SqlParameter("@Membership_Type", Membership_Type));
    alieCommand.Parameters.Add(new SqlParameter("@Parent_Name", Parent_Name));
    alieCommand.Parameters.Add(new SqlParameter("@Parent_Adress", Parent_Adress));

    myConnection.Open();
    SqlDataReader alieReader = alieCommand.ExecuteReader();
    alieReader.Close();
    myConnection.Close();


    SuccessLabel.Text = "Thank you for your interest to join us! Your application will be reviewed and an e-mail will be sent"
    + " to you with details of how you can make your payment and get your membership benefits. Thank you from Casey!";

    AppNameTextBox.Text = "";
    AgeTextBox.Text = "";
    EmailTextBox.Text = "";
    AppAddyTextBox.Text = "";
    ContactTextBox.Text = "";
    SchLocationTextBox.Text = "";
    GradeTextBox.Text = "";
    SchoolTextBox.Text = "";
    MajorTextBox.Text = "";
    ParentNameTextBox.Text = "";
    ParentAddyTextBox.Text = "";
    }

    }
    }


    Please help me guys; I don't know what to do.
     
  2. Hi,
    You can name your Conn strings like that, no problem, that part is working.
    As for your code errors. . .It will require more than what you posted to dig into this.
    You are going to need someone to take a look at each of the associated code pages and objects, plus the actual page errors.
    All the best,
    Mark
     
  3. Help me Please!!!

    Wisemax,

    Thanks a lot for your response. Well, The onlineRegister.aspx.cs is the only code page I have in my whole website that has something to do with database. The only other database info I have on my website is the one found in web.config and as you have seen above (in my previous post, those are the code I wrote).

    I just don't know what is going on. I have checked my c# code for errors, but can't find it. I have tested the connection style locally and it works. I can't understand whats happening.
     
  4. Really you cannot think that this is the only page you'll need to look at. Your codes has alot of arguments and values being passed. So there are other pages that maybe effecting it. I suggest for now you create a simple slim down version of the script (something that is one page). Hard code everything no variables. What you want to test is that you are able to connect to the SQL server and add a data to the database.
     
  5. I have done every possible thing I know, but can anyone just show me the best pratices in passing variables in asp.net 3.5?

    I'm having a kind of strange problem. Normally, I add databases in my ASP.Net websites using the Solution Explorer. I right click on the App_Data folder and click add new item, select the databse and click add. Now I am trying to do it but its giving an error that reads:

    "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed".

    Please tell me; how can I solve this problem?
     
  6. What kind of database your web application is trying to connect to? Do you have a copy of the connection string?
     
  7. No; I am not connecting to any database. I am just trying to create the database first in my website before doing anything with connectionstring. Just adding a new databse from Visual Web Developer.

    I am trying to add a new database to my new website project. I have gone to Solution Explorer and right clicked on the App_Data and clicked on Add New Item; selected the SQL Server Database and clicked add. Normally, this would work but now, I try to do it, but its throwing an error that reads:

    "Failed to generate a user instance of SQL Server due to failure in starting the process for the user instance. The connection will be closed closed".
     
  8. It sounds like you're trying to create a SQL Express instance on our hosting servers. Is this correct?

    You cannot create a new database. You can only use the SQL addon to your account. For each SQL addon you only get one database.
     
  9. No. I am trying to add a database to my website locally; configure the tables and data befor uploading to your server. I am having this problem locally and just need someone with little experience in Visual Studio to help me out.

    I am not trying to create a database on your server. I am doing this locally to complete my site before I can connect to the database addon. But when I try to create my DB, it throws this error. I need someone with experience in Visual Studio to help me out here please.
     
  10. Hi,
    If you're using Vista "pin" VS to the start menu and right-click it then Run as Admin.
    Even if you are an Admin, then browse your local DB via valid instance from within VS.
    All the best,
    Mark
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page