|
SqlConnection c = new SqlConnection(stringconection);<br />
c.Open();<br />
DataSet ds = new DataSet();<br />
SqlDataAdapter da= new SqlDataAdapter ("select command",c);<br />
da.Fill(ds);<br />
Dropdownlist1.DataSource = ds.Tables[0];<br />
Dropdownlist1.DataValueField = "Column1";<br />
Dropdownlist1.DataTextField = "Column2";<br />
c.Close();
|
|
|
|
|
Goto DropdownList's properties and DataValueField put the PK of Database and DataTextField put the column name which u want to display form Database.
Then Write Method as:
DataSet ds = GetValuesFromDB();
DropdownList1.DataSource = ds;
DropdownList1.DataBind();
ListItem lst = new ListItem("All Values", "0");
DropdownList1.Items.Insert(0, lst);
Where GetValuesFromDB() will contain sql which will return Dataset.The query will have PK and the column name which u want to display.
I hope this will help u.
Thanks and Regards.
|
|
|
|
|
Hi, I have this question about static instances of classes:
Is a static instance of a class unique at the Application level, or there is a different instance for every session?
In other words, does a static field of a non-static class behave like it was in the Application["..."] object dictionary?
Thanks.
______________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA] and the ScrewTurn Software experiment
|
|
|
|
|
|
Thanks, in fact I have did a test and it behaves that way. Cool.
______________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA] and the ScrewTurn Software experiment
|
|
|
|
|
A static instance is just a static reference to a regular instance of the class. Therefore it has the same scope as any static variable.
A static variable is unique at the application level.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: A static variable is unique at the application level.
Cool. I did a test and in fact it works that way.
Thank you.
______________________________________
Tozzi is right: Gaia is getting rid of us.
My Blog [ITA] and the ScrewTurn Software experiment
|
|
|
|
|
I am working on an ASP.NET project where I make a call to a database. I know how to create a key in the web.config file to point to the actual server, but I made a copy of the database on my local computer and want it to point to that.
Real Server:
<add key="ConnectionString" value="Data Source=SERVER-SQLSC1;Initial Catalog=Parts;User ID=user;Password=morecowbell" />
What I tried for localhost:
<add key = "ConnectionString" value = "Data Source = localhost;Initial Catalog=PartsDB;"/>
(I named the copy PartsDB to avoid confusion.)
What am I doing wrong here?
|
|
|
|
|
Just raise your arm and extend your finger in the direction of your pc...
or use server=(local)
|
|
|
|
|
add key = "ConnectionString" value = "Server=(local);Initial Catalog=PartsDB;"
Like that?
I've been having problems pasting...
|
|
|
|
|
You can try wrapping your code in code tags (formatting below the entry textbox).
And yes.
|
|
|
|
|
Then I get this error...
System.Data.SqlClient.SqlException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection
-- modified at 10:29 Thursday 15th June, 2006
What user do I use?
|
|
|
|
|
How are you connecting to your other db? You'll need to supply a db user name and password (probably sa and blank)...
|
|
|
|
|
Real server:
add key="ConnectionString" value="Data Source=SERVER-SQLSC1;Initial Catalog=Parts;User ID=aspuser;Password=crlamo5"
Trying:
add key = "ConnectionString" value = "Server=(local);Initial Catalog=PartsDB; User ID = aspuser; Password=crlamo5
Get error:
System.Data.SqlClient.SqlException: Login failed for user 'aspuser'. Reason: Not associated with a trusted SQL Server connection
|
|
|
|
|
|
Good site...what I can't figure out is why the "aspuser" works on the real server but not on localhost. I can't find anything different with permissions.
|
|
|
|
|
You could always put in the name of your machine rather than (local). worth a try.
|
|
|
|
|
|
A quick simple question:
I want to query access using only script (I'm using VB), then loop through the data? I know this is easy, and I think it's similar to how I do things in ASP, but does anyone know where a simple tutorial is? Also one for script querying SQL would be great.
Thanks
|
|
|
|
|
a little VBScript should do the trick.....
<br />
dim oConn as ADODB.Connection<br />
oConn.Open(ConnectionStringHere)<br />
<br />
dim oRS as new ADODB.Recordset<br />
oRS.Open ("SELECT * FROM SomeTable", oConn)<br />
<br />
while oRS.EOF = false and oRS.BOF=false<br />
call MyProcessingFuntion()<br />
wend<br />
apologies if it's not quite bang on - been a while since I've done ANY VBS :$
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Hello,
I have comming two different columns FirstName and LastName from the datasource. I have no problem in binding it to the gridview. But I need help on how to make FirstName and LastName to be displayed in a single column.
Could some one please help me with that?
Thanks
-L
|
|
|
|
|
select (FirstName + ' ' + LastName) as Name from table
|
|
|
|
|
Yeah I have already done that. But I need to be able to pass these First and Last names to a different page. If I do like you said in the selection of the table I will have to use function like split to split the fname and lname and then display fname and lname seperatley.
Looks like I will have manipulate in the table selection itself.
Thanks for the input,
-L
|
|
|
|
|
use seperatly
select FirstName,Lasntname, (Firstname + ' ' + Lastname)as Name from table
|
|
|
|
|
'ats works too and we can hide the FirstName and LastName columns in the grid. I will try that way .. I mean either way its gonna take enough time in my situation. But I like this idea.
Thanks
-L
|
|
|
|