Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
yvette
Yak Posting Veteran
74 Posts |
Posted - 2010-09-13 : 04:55:11
|
| hi,i'm using asp.net c# and sql server 2008.i'm facing a problem when create registration form.How do i insert the data that user choose to sql server from drop down list???thanks... |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-09-13 : 05:10:10
|
| Post some sample data & please explain more in detail on what exactly you want.Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
|
rohitvishwakarma
Posting Yak Master
232 Posts |
Posted - 2010-09-13 : 05:19:27
|
| hi,you can the selection of the user from drop down list as follows:I hope you have a submit/save button to store the registration data.1)In the Codebehind page (C#)void btnSubmit_Click(object sender,EventArgs e){ string strSelected= ddlYourDropDownList.SelectedValue ; pass strSelected to your Data Layer}2) In the Data Layer / or whatever class you are using to store data:void SaveData(string strSeleted){ string strSql = "INSERT INTO YourTableName(YourColumnName) VALUES(" + "'" + strSeleted +"')" SqlConnection Connection= new SqlConnection(ConfigurationManager.ConnectionStrings["YourConnectionStringName"].ConnectionString); SqlCommand Command=new SqlCommand(); Command.CommandText = strSql ; Command.CommandType = CommandType.Text; Command.Connection = Connection; Command.Connection.Open(); int res= Command.ExecuteNonQuery(); // res will give you the number of rows affected. Command.Dispose(); Connection.Dispose();}I hope this is your requirement. |
 |
|
|
|
|
|