Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing a final year project on music store in Asp.Net. But i don't know how to connect Asp.Net with Sqlserver(integrated sqlexpress in vs2008). So i need someone to help me by creating a asp.net page with a textbox and button. After entering a text into the texbox and clicking the button should create a table with name from textbox entry in database.
Please help me.
I think this will help me with the connection problems.
Posted
Updated 30-Dec-10 18:25pm
v2

This is one of the very basic thing. I suggest you to spend sometime learning ASP.NET before you start the project.

I am saying this because even if I give you the code for your above requirement, I am sure you will come again and again with a new simple issue. You won't be able to complete the project in time.

So it's better to spend sometime understanding the basics and then start developing.

There are lots of tutorial available on the web. The best place to start is http://www.asp.net/[^].

Data-access tutorials can be found here: http://www.asp.net/data-access/tutorials[^]

You will find the answer for your above query here: http://www.w3schools.com/aspnet/aspnet_dbconnection.asp[^]

And last but not the least, take the maximum use of search engines like Google. Google is programmers best friend.
And for articles and tutorials CodeProject rocks. You can find anything and everything here.

I hope this helps.
Cheers!
 
Share this answer
 
Comments
sharathu7 31-Dec-10 1:18am    
yeah i know that... i had gone through some online tutorials on asp.net... and had designed my pages including the login forms,etc. But when came into executing queries i was not able to find a good tutorial for making a sql connection... so i am here. anyways i will look into the tutorials you specified and try to do it... thank u mate...
Ankur\m/ 31-Dec-10 1:19am    
You are welcome! :)
Try Following query it will create table in database.
public void AddTopic(string _name)
{
string _sql = "Create Table Tbl" + _name + "(SrNo Varchar(40) Primary Key,Query NVarchar(max),TopicId Varchar(40) References TblTopics(TopicId),Description NVarchar(max),URL Varchar(500))";
DataHelper.ExecuteCommand(_sql);
}
 
Share this answer
 
Comments
sharathu7 31-Dec-10 0:50am    
it will be helpful if u can upload a asp.net page with the one i asked. B'cos i dont know how to connect it with sqlexpress.
Ankur\m/ 31-Dec-10 0:50am    
I copy pasted your code. It's not working. :(
TejuKrishna 31-Dec-10 0:55am    
My datahelper class contain this method please try it
public static void ExecuteCommand(string _command)
{
try
{
sqlcn.Open();
sqlcmd = new SqlCommand(_command, sqlcn);
_records = sqlcmd.ExecuteNonQuery();
}
catch (Exception)
{

throw;
}
finally
{
sqlcn.Close();
}
}
you can set Sqlconnection sqlcn=new SqlConnection("Paste Here Your Connection String");
TejuKrishna 31-Dec-10 1:01am    
USe This connection string for sqlexpress. as well modify to map your datasource location
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
sharathu7 31-Dec-10 1:10am    
sorry getting error...

Line 15: public partial class adminpage_addlanguage : System.Web.UI.Page
Line 16: {
Line 17: Sqlconnection sqlcn = new SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True";
Line 18:
Line 19: protected void Button3_Click(object sender, EventArgs e)
 
Share this answer
 
Comments
sharathu7 31-Dec-10 1:18am    
thank u mate
sharathu7 1-Jan-11 2:11am    
A new problem now... Cannot open database "ASPNETDB" requested by the login. The login failed. Login failed for user 'seven\sharath'. this is my code... SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True;User Instance=True"); con.Open(); SqlCommand cmd = new SqlCommand("insert into albumdetails(id,albumname,albumlanguage,musicdirector,copyright,year,price,discount,rating) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "')",con); cmd.ExecuteNonQuery(); con.Close();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900