Showing posts with label enter. Show all posts
Showing posts with label enter. Show all posts

Thursday, March 29, 2012

pop ups not working

Hi

i am working on a project which involves pop up windows to enter information which worked fine at uni

i brought the exact same project home and the popups dont 'popup, nothing happens

i've allowed popups in internet explorer, but they still dont work

is there something else i've overlooked??

cheers!!

hehe

sorry for wasting space

just remembered i took a line of code out just before i left uni yesterday that stopped popups working

blah!!

Monday, March 26, 2012

Populate a ListBox based on database search

I am trying to populate a ListBox with values retrieved from a database based on a search. I have a TextBox in which the user will enter the text they wish to search for, a Button which will submit the text, and then a ListBox which is invisible until values are returned from the database. I have a SqlDataSource with a SelectCommand saying "SELECT * FROM [table] WHERE [name] LIKE '@dotnet.itags.org.Parameter'". I want to know how to bind the value in the TextBox to the "@dotnet.itags.org.Parameter" in the Sql statement. I am quite new at programming, and I'm sure this is quite a simple task. Any help would be appreciated.

MYSQL:

myCommand.Parameters.Clear();
myCommand.CommandText = "SELECT * FROM [table] WHERE [name] LIKE (?)";
myCommand.Parameters.Add(new OdbcParameter(null, txtSearch.Text));

MSSQL:

myCommand.Parameters.Clear();
myCommand.CommandText = "SELECT * FROM [table] WHERE [name] LIKE @.search";
myCommand.Parameters.Add(new SqlParameter("@.search", txtSearch.Text));


Thanks for the reply. Where would I put this code? I'm using MSSql, but I am not using any stored procedures. All my SQL code is on my .aspx page. Should this go somewhere on my .aspx page or in my VB codebehind?

This would go in your code behind, in the onclick method from your button (double click your submit button and you'll go automatically to your onclick method).

Remember the code I gave in the example is C# code, I don't know the correct syntax in VB.net but it should get you started.


This should help:

http://www.asp.net/learn/dataaccess/default.aspx?tabid=63

Cheers