Hi guys,

1.Can anyone help me how should i design my first web page in asp.net using C#
2.which should have 4textboxes and 2buttons
3.how can i connect the asp.net with sql server 2008
4.how can i insert my first record in sql server db please please help then i would carry on my self.

Thanks in advance for your help.

Recommended Answers

All 2 Replies

*Go to visual studio File menu->open->web site
*give one name to webpage eg myfirstweb.aspx
*Then add the controls u need into the web form from tool box
*Its suggested to add a table so that formatting would be easy(And place all the controls inside the table cells)
*Use a stored procedure or query for inserting records.(stored procedure suggested).
*go to web config and give your connection string
*give the coding in the button click event to store the text box values into your dataabase.

<!-- configuration manger adding connection string -->
<connectionStrings>
	
    <add name="ConnectionStringName" connectionString="Connectionstring;" providerName="System.Data.Odbc"/>
	</connectionStrings>
/*calling stored procedure or function from Cs class  for inserting data*/
  protected int RunProcedure(string storedProcName, IDataParameter[] parameters, out int rowsAffected)
        {
            int result;
connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
            Connection = new SqlConnection(connectionString);

            Connection.Open();
            SqlCommand command = BuildIntCommand(storedProcName, parameters);
            rowsAffected = command.ExecuteNonQuery();
            result = (int)command.Parameters["ReturnValue"].Value;
            Connection.Close();
            return result;
        }
/* inserting values */
//[DataObjectMethod(DataObjectMethodType.Insert)]
        public int InsertRow(string pcode,string name)
        {
            int RowsAffected = 0;
            int Result = 0;

            SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("pcode",pcode ),
					new SqlParameter("name",name) 
				};
            Result = RunProcedure("sp_port_Insert", parameters, out RowsAffected);
            return Result;
        }

        [DataObjectMethod(DataObjectMethodType.Update)]
        public int InsertRow()
        {
            int RowsAffected = 0;
            int Result = 0;

            SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("Parameter1",textbox1 ),
					new SqlParameter("Parameter2",textbox2) 
				};
/* use the appropriate calss name  example class cs = new cs() then cs.RunProcedure("sp_Insert", parameters, out RowsAffected)*/
    
            Result = RunProcedure("sp_Insert", parameters, out RowsAffected); //calling function in .cs file defined earlier.
            return Result;
        }

if you are using sql,mysql etc you want to add the namespace(Header Files in c) needed for sql it is using System.Data.SqlClient at the top.Hope you got some basic .If any dout pls contact.If its ok pls mark the thread as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.