hi all,
i want to display some data in dropdown from database using java.please send the code

public class TheCode {
    public void getDataFromDB(Dropdown b) {
        b.populateList();
    }
}

hi friend,
first establish the connection
example:
step 1: import sql package(import java.sql.*;)
step 2: initiate driver:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
step 3:creat connection:
Connection conn = DriverManager.getConnection(url,username,password);
url --> "jdbc:odbc:DSN Name"
DSN(data source name).
user -->user name of the server
password -->password of the server
this 3 parameters are String.
step 4:create statement:
Statement stmt = conn.createStatement();
step 5:use result set to access the records in the table
ResultSet rset = stmt.executeQuery("SELECT * FROM Table_Nmae");
step 6:this code is used to display the value of the Table_Name from first to last row
while(rset.next())
System.out.println(rset.getString(1));
getString(1) -->means first column(field) value of each row

this are the example for list the database values.if you want to list it as dropdown by using "JComboBox" class its in java swing(jdk1.5).
example:
JComboBox object_Name = new JComboBox();
we use object_Name.addItem(rset.getString(1)); to System.out.println(rset.getString(1));

try it...

i have problem i want retriving value in database in dropdownlist and i want insert the next same dropdownlist plz check where iam wrong

using System.Data.SqlClient;

public partial class Default4 : System.Web.UI.Page
{
    string brandno,s1 ,s2,pno ;
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = ConnectionClass.getconnection();
        SqlCommand cmd = new SqlCommand(
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.