473,386 Members | 1,775 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.

SQL Data Source

Hi All,

I have change select command of a sql data source when user clicking a
button
sds1.SelectCommand = "Select DivisionCode, Description FROM DivisionMst
WHERE Description LIKE @Description";
sds1.SelectParameters.Clear();
sds1.SelectParameters.Add("Description",TypeCode.S tring,
txtDescription.Text);

I have two question.
1. Why @Description didnot change to txtDescription value?
2. How to refresh GridView that bind to sds1 (SQL Data Source)?

TIA
Gun
Aug 16 '06 #1
2 1596
Gun,
pls post some snippet code and please elaborae more
if u want to refresh GridView then call DataBind
grid.Databind()
Patrick
"Gunawan" <jg**********@gmail.comwrote in message
news:eF**************@TK2MSFTNGP03.phx.gbl...
Hi All,

I have change select command of a sql data source when user clicking a
button
sds1.SelectCommand = "Select DivisionCode, Description FROM DivisionMst
WHERE Description LIKE @Description";
sds1.SelectParameters.Clear();
sds1.SelectParameters.Add("Description",TypeCode.S tring,
txtDescription.Text);

I have two question.
1. Why @Description didnot change to txtDescription value?
2. How to refresh GridView that bind to sds1 (SQL Data Source)?

TIA
Gun

Aug 16 '06 #2
Here is the code that I wrote.

if (btnFilter.Text == "Filter Off")
{ sds1.SelectCommand = "SELECT [DivisiID], [KodeDivisi],
[Deskripsi] FROM [ldc_divi_mst]"; }
else
{ string strWhere = "SELECT [DivisiID], [KodeDivisi], [Deskripsi]
FROM [ldc_divi_mst]";
if (txtKodeDivisi.Text != "")
{ strWhere += "WHERE [KodeDivisi] LIKE @KodeDivisi"; }
if (txtDeskripsi.Text != "")
{ if (txtKodeDivisi.Text != "")
{ strWhere += " AND [Deskripsi] LIKE @Deskripsi"; }
else { strWhere += "WHERE [Deskripsi] LIKE @Deskripsi"; }}

sds1.SelectCommand = strWhere;
sds1.SelectParameters.Clear();
sds1.SelectParameters.Add("KodeDivisi",TypeCode.St ring,
txtKodeDivisi.Text);
sds1.SelectParameters.Add("Deskripsi",TypeCode.Str ing,
txtDeskripsi.Text);
}
sds1.Select(DataSourceSelectArguments.Empty);
gv1.DataBind();

it seems that gv1 (gridview) did not populate the right data and I think it
cause by sds1 (SQLDataSource) that does not populate the right query
(Command) and always look like this

SELECT [DivisiID], [KodeDivisi], [Deskripsi] FROM [ldc_divi_mst]WHERE
[Deskripsi] LIKE @Deskripsi

or like this

SELECT [DivisiID], [KodeDivisi], [Deskripsi] FROM [ldc_divi_mst]WHERE
[KodeDivisi] LIKE @KodeDivisi AND [Deskripsi] LIKE @Deskripsi

I would like to change parameter deskripsi and kodedivisi to a value.

Regards,
Gunawan
"Patrick.O.Ige" <na********@hotmail.comwrote in message
news:ev**************@TK2MSFTNGP02.phx.gbl...
Gun,
pls post some snippet code and please elaborae more
if u want to refresh GridView then call DataBind
grid.Databind()
Patrick
"Gunawan" <jg**********@gmail.comwrote in message
news:eF**************@TK2MSFTNGP03.phx.gbl...
>Hi All,

I have change select command of a sql data source when user clicking a
button
sds1.SelectCommand = "Select DivisionCode, Description FROM DivisionMst
WHERE Description LIKE @Description";
sds1.SelectParameters.Clear();
sds1.SelectParameters.Add("Description",TypeCode. String,
txtDescription.Text);

I have two question.
1. Why @Description didnot change to txtDescription value?
2. How to refresh GridView that bind to sds1 (SQL Data Source)?

TIA
Gun


Aug 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Monica Ferrero | last post by:
Hi! I'm not sure if this is the most adequate mySQL list for this post. If not, please indicat me which one I should use... I'm using Tomcat 4.1.24 with Apache 2 and MySQL 4.0.13. I have the...
2
by: Greg Strong | last post by:
Hello All, I've written code in a test database with test data. Everything seems to be working except compact database in VB code per http://www.mvps.org/access/general/gen0041.htm. The reason I...
18
by: xarax | last post by:
Greetings, What is the general practice, usual and customary way, of including a data file into a source file? I have some large data structures defined as source similar to: ...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
5
by: rogsonl | last post by:
My computer was moved last week, and the company changed the network groups we work on. As a result, one of the main benefits from Whidbey (database connectivity) no longer works. Situation: 1....
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
7
by: John J. Hughes II | last post by:
I have a DataGridView with a TextBoxColumn. I setting the data source to a List<stringvalue in a static class. The list is filled from a background thread. So far all is fine and it works...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
0
by: BillE | last post by:
I am using Visual Studio 2005 to create a web site which includes reports. The web site has several sub-folders. When working with reports I can't get the website data sources (classes and...
0
natalie99
by: natalie99 | last post by:
Hey people! Being so lacking in access knowhow I have turned to good old 'asking the smart people' again! I need to create a query or lookup table (although I have had zero success with lookups...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.