|
if(combobox2.text==" teachers name")
str="t_name"; //giving field name
//many if statements here
strQuery = " SELECT * FROM tbl1,tbl2,tbl3 WHERE tbl1." + str + "=" + textBox1.Text+"AND
tbl1.t_id=tbl2.tb_id AND tbl.t_id=tbl3.tb3_id ";
it works
but when i do
//tablename=combobox1.text;
//or
tablename="tbl1";
strQuery = " SELECT * FROM tbl1,tbl2,tbl3 WHERE" + tablename + "." + str + "=" +
textBox1.Text+"AND tbl1.t_id=tbl2.tb_id AND tbl.t_id=tbl3.tb3_id ";
it gives error
$h@ma!|@
|
|
|
|
|
what error?
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
some exception is handled at runtime
$h@ma!|@
|
|
|
|
|
use try catch and catch the exxception
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
strQuery = " SELECT * FROM tbl1,tbl2,tbl3 WHERE" + tablename + "." + str + "=" +<br />
<br />
&textBox1.Text+"AND tbl1.t_id=tbl2.tb_id AND tbl.t_id=tbl3.tb3_id ";
"AND" operator will be join with Textbox1.Text
so give spance there
Best Regard
Pathan
GOD HELP THOSE WHO HELP THEMSELVES
|
|
|
|
|
strQuery = " SELECT * FROM tbl1,tbl2,tbl3 WHERE " + tablename + "." + str + "=" +
textBox1.Text+" AND tbl1.t_id=tbl2.tb_id AND tbl.t_id=tbl3.tb3_id ";
User this string
best Regard
Pathan
GOD HELP THOSE WHO HELP THEMSELVES
|
|
|
|
|
still no progress!!
$h@ma!|@
|
|
|
|
|
check this also "tbl.t_id=tbl3.tb3_id"
What is tbl?
Best Regard
Pathan
GOD HELP THOSE WHO HELP THEMSELVES
|
|
|
|
|
well tbl is the tablename in databases..actually these are not the actual tablenames but it was to simplify the query to post
$h@ma!|@
|
|
|
|
|
I've always found using string.format rather than concatentation helps to simplify things like this and makes the code more readable so you can find syntax errors better.
Of course using a stored proc, as you should, this is not an issue.
only two letters away from being an asset
|
|
|
|
|
anybody would like to help me on how to add a datetimepicker in an asp.net application...
thank you
start a new beginning in every ending; thats what life for......
|
|
|
|
|
Get it[^]
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
Hi everyone,
My problem is that I have a gridview, which has an objetdatasource as it´s datasource. The objectdatasource is filled with a method that retrieves a datatable. All this is just fine, but when I try to update my gridview, I need to write a method for the objectdatasource to update the datatable, but I can´t find a way to pass the updated field as a parameter to this method. Is there an specific way of doing this??? or is there a better way to do what I need??? I am not using "directly" a table from the database because I need to do some operations with the data first. I would rally appreciate any answer on this, my work depends on this!!!! Thanks in advance
|
|
|
|
|
|
Hi Guru's
I know this sound elementary but here goes, how can I get the cell value on a datagrid?
By the way Im using asp:TemplateColumn instead of BoundColumn e.item.cells(3).text does return the cell value when on BoundColumn mode but not in asp:TemplateColumn
Dom
-- modified at 23:11 Wednesday 11th July, 2007
|
|
|
|
|
Take Label in Template Column
U can get value By ((Label)e.Item[index].FindControl("lblid")).Text
Best Regard
Pathan
GOD HELP THOSE WHO HELP THEMSELVES
|
|
|
|
|
Hi I tried to use an if statement to determine when myCon is null when no item of ListBox2 is selected like the following.
<br />
Dim i As Integer<br />
Dim myCon As OdbcConnection<br />
Dim cmd as OdbcCommand<br />
myCon = New OdbcConnection("Driver={MySQL ODBC 3.51Driver}; Server=myServer;Database=myDB;User=myUserassword=myPass;Option=3;")<br />
<br />
For i = 0 To ListBox2.Items.Count - 1<br />
If ListBox2.Items(i).Selected Then<br />
<br />
cmd = New OdbcCommand("SELECT * FROM myTable where Professions = '"& ListBox2.Items(i).Text &"' ")<br />
End If<br />
Next<br />
If Not IsNothing(myCon) then <br />
myCon.Open()<br />
<br />
cmd.Connection = myCon<br />
<br />
Dim ds As New DataSet<br />
<br />
Dim ad As New OdbcDataAdapter(cmd)<br />
<br />
ad.Fill(ds)<br />
<br />
Me.ListBox2.DataSource = ds<br />
<br />
Me.ListBox2.DataTextField = "Professions"<br />
<br />
Me.ListBox2.DataBind()<br />
End IF<br />
When viewed in the browser I get the exception "Object reference not set to an instance of an object". I have read that the most common causes of this exception are not declaring the variables before using them, bad scoping, and not using the key word New when instantiating. I thought I have made sure that the afore mentioned causes are not the causes of the error I'm getting but obviously there is something wrong with my code. Please help me identify the cause of the exception, I just can not see what it could be at the moment. Thank you in advance for your help.
|
|
|
|
|
What's wrong with the selectedItem property ?
When you get this error, you need to step through the code and work out what is Nothing. You really have a list box called 'ListBox2' ???
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
This has popped up a few times Christian, links to the MSDN entries on the ListBox class have been provided at least once before, but I don't think the poster has a lot of, (if any), understanding of the responses that have been given thus far, or of what he's doing.
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
There are a couple of things you can do here. The first (and best) case would be to set a breakpoint at the first line of code and step through the function to see where it breaks. If you watch the variables as you step through, you should be able to figure out where the null value is quite quickly.
The second method would be to wrap this up in a Try/Catch block and set a breakpoint in the Catch. The exception that was thrown would contain full information including a stack trace which you can use to identify which line of code is failing.
My choice - go with option 1. Part of becoming a professional programmer is learning how to debug code effectively. As a general note, you should only come to CP if you have a problem after you have stepped through the code. Seriously, debugging the code is a great way to learn how to problem solve.
|
|
|
|
|
I have a gridview that loads about 2-50 records. While the query in SQL Query analyzer takes less than a couple seconds to run it takes forever for the gridview to load the data from an sqldatasource in sqldatareader mode. Has anybody has experienced somtehing like this?
|
|
|
|
|
Well, a grid view is not loading data, you should have code that does this, which won't be much slower, but then it needs to also generate HTML to display it, along with all the doohickeys you have turned on.
A repeater would be faster, but it does nothing, you have to totally style it yourself.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am not sure about the term "loading data" but it takes forever to execute the gridview.databind. I guess it takes forever to create the HTML code.
|
|
|
|
|
I am working on a job posting web site and I am using the index server to be able to search thru individual jobs that get ftp up.
The problem is how do I truncate the data or extract the data out of the characterization.
Here is an example of the contents of my characterization.
15010, CEV Demo Chief Engineer - Space .
Category: Engineering.
Region: CA-Los Angeles/Orange Counties.
City: El Segundo.
State: CA.
Rate: $60.00 - $65.00.
Duration: 6 - 12 Months.
Description: Technical Integrity, CEV, Spacecraft Systems~.
RESPONSIBILIITES:. Responsible to the CEV Demo IPT Leader and Program
I need to bind to a gridview to the first line... that would only be the job number. Then I want the rest for the next column to have the job title. After that, the description is my keywords for my next column and then a combo of State and City in one column and the final column to have the Rate.
I thought I could use substrings and pathindex to get the individual data out, but that didn't work.
thanks
mjc
|
|
|
|
|
Ok, I got it to work. What I did was saved query result into a dataset and then using string functions to get my data out and then create a datatable and added each row with data from the dataset.
Dim accessConnection As OleDbConnection = New OleDbConnection("Provider=MSIDXS")
Dim accessCommand As New OleDbCommand(query, accessConnection)
Dim newjobsDataAdapter As New OleDbDataAdapter(accessCommand)
Dim myDataSet As New DataSet()
Dim newjobsDataTable As New DataTable("newjobs")
newjobsDataAdapter.Fill(myDataSet, "newjobs")
Dim dataTableRowCount As Integer = newjobsDataTable.Rows.Count
Dim myDataTable As DataTable = myDataSet.Tables(0)
Dim tempdata As String
Dim spc1 As Integer
Dim spc2 As Integer
Dim spc3 As Integer
Dim spc4 As Integer
myDataTable.Columns.Add(New DataColumn("ID", GetType(Integer)))
myDataTable.Columns.Add(New DataColumn("JobID", GetType(Integer)))
myDataTable.Columns.Add(New DataColumn("JobTitle", GetType(String)))
myDataTable.Columns.Add(New DataColumn("Keywords", GetType(String)))
myDataTable.Columns.Add(New DataColumn("Location", GetType(String)))
myDataTable.Columns.Add(New DataColumn("Rate", GetType(String)))
For i = 0 To myDataTable.Rows.Count - 1
myDataTable.Rows(i)("ID") = i + 1
tempdata = myDataTable.Rows(i)("characterization")
spc1 = InStr(myDataTable.Rows(i)("characterization"), ",")
spc2 = InStr(myDataTable.Rows(i)("characterization"), ". Category")
myDataTable.Rows(i)("JobID") = Convert.ToInt32(Mid(tempdata, 1, spc1 - 1))
myDataTable.Rows(i)("JobTitle") = LTrim(Mid(tempdata, spc1 + 2, spc2 - 8))
spc1 = InStr(myDataTable.Rows(i)("characterization"), "Description")
spc2 = InStr(spc1, myDataTable.Rows(i)("characterization"), "~.")
myDataTable.Rows(i)("Keywords") = LTrim(Mid(tempdata, spc1 + 13, spc2 - spc1 - 12))
spc1 = InStr(myDataTable.Rows(i)("characterization"), "State")
spc2 = InStr(spc1, myDataTable.Rows(i)("characterization"), ".")
spc3 = InStr(myDataTable.Rows(i)("characterization"), "City")
spc4 = InStr(spc3, myDataTable.Rows(i)("characterization"), ".")
myDataTable.Rows(i)("Location") = LTrim(Mid(tempdata, spc1 + 7, spc2 - spc1 - 7)) + ", " + LTrim(Mid(tempdata, spc3 + 6, spc4 - spc3 - 6))
spc1 = InStr(myDataTable.Rows(i)("characterization"), "Rate")
spc2 = InStr(spc1, myDataTable.Rows(i)("characterization"), ".")
myDataTable.Rows(i)("Rate") = LTrim(Mid(tempdata, spc1 + 6, spc2 - spc1 - 6))
Next
Dim myDataView As DataView = myDataTable.DefaultView
If myDataTable.Rows.Count > 0 Then
GridView1.DataSource = myDataView
GridView1.DataBind()
End If
Hope this helps other people.
|
|
|
|