how do i retrive the data from one cell in the sql database?
-
hi guys i would like to retrive the data of One cell of the sql database's table i already know the command will be like this: select age from kids where nric = 'sss' this command statement would retrive only 1 result however i dont know the sysntex to use this command statment with in asp.net (c# coding side) could anyone show me how it is done pls?
-
hi guys i would like to retrive the data of One cell of the sql database's table i already know the command will be like this: select age from kids where nric = 'sss' this command statement would retrive only 1 result however i dont know the sysntex to use this command statment with in asp.net (c# coding side) could anyone show me how it is done pls?
-
hi guys i would like to retrive the data of One cell of the sql database's table i already know the command will be like this: select age from kids where nric = 'sss' this command statement would retrive only 1 result however i dont know the sysntex to use this command statment with in asp.net (c# coding side) could anyone show me how it is done pls?
-
it says Error 51 The type or namespace name 'sqlconnection' could not be found (are you missing a using directive or an assembly reference?)
-
i already added using System.Data.SqlClient; if this is not correct pls kindly describe what i shld do pls
hi .. here is some code for connecting to database.. i think this would help you.. make necessary changes.. this is just to show you how we can connect to the db.. put connection string in web.config file using System; using System.Data; using System.Configuration; using System.Data.SqlClient; public class dbClass { private SqlConnection con; private SqlCommand com; private SqlDataReader dr; private SqlDataAdapter da; private DataSet ds; public dbClass() { con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["conString"].ToString()); } /// /// Open an Sql connection. /// /// sqlconnection public SqlConnection GetConnection() { try { if (con.State == ConnectionState.Open) { con.Close(); } con.Open(); } catch (Exception ex) { string err = ex.Message.ToString(); } return con; } /// /// Executes a query with SqlDataAdapter /// /// sql query /// DataTable public DataTable GetAdapter(string sql) { try { com = new SqlCommand(sql, GetConnection()); com.CommandTimeout = 0; da = new SqlDataAdapter(com); ds = new DataSet(); da.Fill(ds); return ds.Tables[0]; } finally { con.Close(); } }
-
it says Error 51 The type or namespace name 'sqlconnection' could not be found (are you missing a using directive or an assembly reference?)
hi u can see this code and do it string strCmd="select age from kids where nirc='sss'"; Sqlcommand cmd =new sqlCommand(strCmd,con); cmd.CommandType=CommandType.Text; con.open(); DataReader dr=cmd.ExecuteReader(); while(dr.read) { // code to populate data example u want to populate to combo box then u can writecode like this cmdAge.add.item(dr.GetValues[1]); } try with this code i hope u will come out of the problem tell me confirm once ok
-
hi u can see this code and do it string strCmd="select age from kids where nirc='sss'"; Sqlcommand cmd =new sqlCommand(strCmd,con); cmd.CommandType=CommandType.Text; con.open(); DataReader dr=cmd.ExecuteReader(); while(dr.read) { // code to populate data example u want to populate to combo box then u can writecode like this cmdAge.add.item(dr.GetValues[1]); } try with this code i hope u will come out of the problem tell me confirm once ok
actually in my web.config i already have an connection string called HASDBConnectionString1 what i basically need is ONE value(int) while using the HASDBConnectionString1 connectionstring name in my web.config my query is queryed by the key column so it always retrun only 1 value i am using asp.net2 (2005) and sql server 2005