473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

connection to droup down list

hi,
when we cerate a data base in sql server .
how we are get that data in droup down box?
Jan 13 '08 #1
2 1079
Shashi Sadasivan
1,435 Expert 1GB
You will have to query the data you want from your database
and store it in a dataset or dataTable. and then set the dataSource of the dropdown list to the dataset (specifying the field you want it to be bound to)

Although I cannot know what stage you are at, so cant specifically provide much help.
Jan 14 '08 #2
kunal pawar
297 100+
you can bind drop down box to any table from your database

1) create sql sever conection object
2) create command for fetch data from table, Adapter and Dataset object
3) fill your Dataset
4) dropdown1.datasourse = ds
5) dropdown1.datavalue = field name
dropdown1.datatext = field name
6) dropdown1.databind()

Expand|Select|Wrap|Line Numbers
  1. con = New SqlConnection(ConnectionStrings)
  2. con.Open()
  3. cmd = New SqlCommand("Select query")
  4. da = new sqldataadapter(cmd,con)
  5. da.fill(ds)
  6. dropdown1.datasourse = ds
  7. dropdown1.DatavalueField = "field name"
  8. dropdown1.DataTextField = "field name"
  9. dropdown1.databind()
  10.  
  11. or 
  12.  
  13. con = New SqlConnection(ConnectionStrings)
  14.                     con.Open()
  15.                     cmd = New SqlCommand()
  16.                     cmd.Connection = con
  17.                     cmd.CommandText = ""
  18.                     Rs = cmd.ExecuteReader()
  19.                     cboLocation.Items.Clear()
  20.                     'cboLocation.Items.Add("Select")
  21.                     'Response.Write("rt " & strloc)
  22.                     If Rs.HasRows Then
  23.                         cnt = 0
  24.                         While (Rs.Read())
  25.                             cboLocation.Items.Add(Rs(0).ToString())
  26.                             If strloc = (Rs(0).ToString()) Then
  27.                                 i = cnt
  28.                                 txtIP.Text = Rs(1).ToString()
  29.                                 txtCno.Text = Rs(2).ToString()
  30.                             End If
  31.                             cnt = cnt + 1
  32.                         End While             
  33.                     End If
Jan 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
0
by: bob .net | last post by:
Server exploI have recently installed Visual Studio .Net 2002 on my workstation running XP Professional. I can connect to local Access and MSDE databases successfully using ADO .Net. I can also...
2
by: Lior | last post by:
Hi, I have an ASP.NET website that crashes under heavy load. I use a SQL Server DB. I get around 5500 hits per day. I keep getting the timeout expieried connection pool error. Sometimes it even...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
2
by: Orit | last post by:
Hello . Please find below my questions - I hope some of the ASP.NET experts of this forum will answer to those beginner's questions : My Web site should be able to work with either SQL Server...
11
by: Alexnb | last post by:
Hello internet. I am wondering, is there a simple way to test for Internet connection? If not, what is the hard way :p -- View this message in context:...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.