Showing posts with label value. Show all posts
Showing posts with label value. Show all posts

Wednesday, March 28, 2012

TableAdapters using values

I have created a data access layer, have a datset with several tables. In VB I would like to access a the value of a particular cell, put that value into a variable. I am unsure how to do this. So far I have,

1Imports DataSet1TableAdapters2~~~~~~34Dim testID = Request("tid")56Dim levelAs Integer = 07Dim testsTableAdapterAs New TestsTableAdapter89level = testsTableAdapter.GetTestsByTestID(testID).Rows(0).Table.Columns(1)10

I know that this is incorrect, however I wish to get the value held in row 1 column 2. Any help would be much appreciated.

Hi,

Based on my understanding, you want to get the value held in particular cell by DataAdapter. If I have misunderstood you, please feel free to tell me, thanks.

 
Dim constrAs String =""'your connection stringDim connectionAs SqlConnection =New SqlConnection(constr)Dim sqlselAs String ="select * from test"Dim sdaAs SqlDataAdapter =New SqlDataAdapter(sqlsel, connection)Dim dsAs DataSet =New DataSet() sda.Fill(ds,"table")Dim levelAs Integer = ds.Tables("table").Rows(1)(2)
 Hope this can help you.

Try this

SqlConnection conn= new SqlConnection("YOUR CONNECTION STRING")
sql = "select * from TableName"
SqlDataAdapter ad = new SqlDataAdapter(sql, conn)
DataSet DS = new DataSet()

ad.Fill(DS,"TableName") // OR ad.Fill(DS.Tables(0))

Dim lvl As Integer
lvl = (int) DS.Table(0).Rows(1)


thanks for replying.

I was hoping to do it without setting a connection string or inputting SQL into the code. I want the dataset in my DAL to take care of this. Is there any way for the tableadapter to populate a new dataSet?


Please refer to this thread below

http://forums.asp.net/p/1187777/2031770.aspx#2031770

This might give you an idea

Monday, March 26, 2012

tabstop of a textbox

Hi all,
I need to allow users to copy the value of a TextBox but I don't want to
allow them to edit the value. I am able to achieve this by setting the
ReadOnly property to true. But now when the user clicks tabs to navigate
through the controls on the form, I don't want the readonly textbox to get
the focus. In VB6, I used to set the TabStop property to false. How can I
achieve this in ASP.Net?
Thanks.
-NikhilHi,
Set the TabIndex property of the TextBox server control to -1.
"Nikhil Patel" <npatel_wsystems@.hotmail.com> wrote in message
news:#rzFzufiEHA.1652@.TK2MSFTNGP09.phx.gbl...
Hi all,
I need to allow users to copy the value of a TextBox but I don't want to
allow them to edit the value. I am able to achieve this by setting the
ReadOnly property to true. But now when the user clicks tabs to navigate
through the controls on the form, I don't want the readonly textbox to get
the focus. In VB6, I used to set the TabStop property to false. How can I
achieve this in ASP.Net?
Thanks.
-Nikhil

tabstop of a textbox

Hi all,
I need to allow users to copy the value of a TextBox but I don't want to
allow them to edit the value. I am able to achieve this by setting the
ReadOnly property to true. But now when the user clicks tabs to navigate
through the controls on the form, I don't want the readonly textbox to get
the focus. In VB6, I used to set the TabStop property to false. How can I
achieve this in ASP.Net?

Thanks.
-NikhilHi,
Set the TabIndex property of the TextBox server control to -1.

"Nikhil Patel" <npatel_wsystems@.hotmail.com> wrote in message
news:#rzFzufiEHA.1652@.TK2MSFTNGP09.phx.gbl...
Hi all,
I need to allow users to copy the value of a TextBox but I don't want to
allow them to edit the value. I am able to achieve this by setting the
ReadOnly property to true. But now when the user clicks tabs to navigate
through the controls on the form, I don't want the readonly textbox to get
the focus. In VB6, I used to set the TabStop property to false. How can I
achieve this in ASP.Net?

Thanks.
-Nikhil

Thursday, March 22, 2012

Tags inside value field of appsettings in web.config

i need to write a xml data inside the value field in web.config file.
it looks likes this

<configuration>
<appSettings>
<add key="MyXmlData" value="<data><type></type>......." />
</appSettings>
</configuration
but i get an error message

some one help meYou need to encode/escape the characters. You can do it manually if you
know all of the rules, but I wrote a little utility for myself that I
know will do it right. I guess I should post the full app at some point,
but the relevant method is:

public string Encode(string input)
{
StringBuilder output = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(output,
CultureInfo.InvariantCulture))
{

XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
xmlWriter.WriteStartElement("element");
xmlWriter.WriteAttributeString("attribute", input);
xmlWriter.WriteEndElement();
xmlWriter.Close();
}
return output.ToString();
}

Just create a simple WinForms app with a textbox to past a value into, a
button that runs the Encode method, and then a textbox for the output
(not label - you want to be able to select the output for copy/paste).

Joshua Flanagan
http://flimflan.com/blog

Tags inside value field of appsettings in web.config

i need to write a xml data inside the value field in web.config file.
it looks likes this
<configuration>
<appSettings>
<add key="MyXmlData" value="<data><type></type>......." />
</appSettings>
</configuration>
but i get an error message
some one help meYou need to encode/escape the characters. You can do it manually if you
know all of the rules, but I wrote a little utility for myself that I
know will do it right. I guess I should post the full app at some point,
but the relevant method is:
public string Encode(string input)
{
StringBuilder output = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(output,
CultureInfo.InvariantCulture))
{
XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
xmlWriter.WriteStartElement("element");
xmlWriter.WriteAttributeString("attribute", input);
xmlWriter.WriteEndElement();
xmlWriter.Close();
}
return output.ToString();
}
Just create a simple WinForms app with a textbox to past a value into, a
button that runs the Encode method, and then a textbox for the output
(not label - you want to be able to select the output for copy/paste).
Joshua Flanagan
http://flimflan.com/blog

Taking a value from one window to another

I want to be able to allow a user to select a word from a list of words, but instead of using a drop down list, I want the user to click a button - which opens a new window containing the list of words, double click on the word (or words) selected, and the value of the word that was double clicked is automatically transferred to a text box in the previous (calling) window. Is this possible in ASP.NET?Passing data back to a parent window is entirely possible via lowly javascript - with or without ASP.NET server technology, but the user interaction method you have decided upon would be a little more unstable across browsers.
window.opener.document.getElementById('textbox1').value = "something";

Taking a value from a dataset

I trying to get a single values from a dataset however I keep getting the following error please help

 Function get_poll_questions() As System.Data.DataSet

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=db\database.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT top 1 * FROM tbl_poll_questions ORDER BY pol_question, rnd(pol_ID)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

strTESTING = DataSet.Tables("tbl_poll_questions").Rows(0)("pol_question").ToString()

return strTesting

End Function

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 116:
Line 117:
Line 118: strTESTING = DataSet.Tables("tbl_poll_questions").Rows(0)("pol_question").ToString()
Line 119:
Line 120: return strTesting

Many thanks in advanceMake sure that the SQL has returned any data. Also make sure that pol_question is the correct name of the column.
Also, I havent seen it done like this:

strTESTING = DataSet.Tables("tbl_poll_questions").Rows(0)("pol_question").ToString()

Try this instead:

strTESTING = DataSet.Tables("tbl_poll_questions").Rows(0).items("pol_question").ToString()

Also, since you are doing this:
dataAdapter.Fill(dataSet)

and not giving a table name...the table is not named "tbl_poll_questions". Rather, it is named just "table" or you could use the index of 0, like:

strTESTING = DataSet.Tables(0).Rows(0).items("pol_question").ToString()

In order to use that table name you would have to do:
dataAdapter.Fill(dataSet,"tbl_pol_questions")

MajorCats

taking the value from dropdownlist

Hi,
I'd like to ask how could be taken the value from DropDownList and to
appropriate it to
cmd.Parameters["@dotnet.itags.org.CITY"].Value = DropDownList1.....
I know that it must be something like this above.
Could you help me!
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.cdm is SqlCommand
@.CITY is VARCHAR(20)
Thanks!
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
DropDownList.SelectedItem.Value
should return the id, and if you want the text, use Text instead of value
"Viktor Popov" wrote:

> Hi,
> I'd like to ask how could be taken the value from DropDownList and to
> appropriate it to
> cmd.Parameters["@.CITY"].Value = DropDownList1.....
> I know that it must be something like this above.
> Could you help me!
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>
>

taking the value from dropdownlist

Hi,
I'd like to ask how could be taken the value from DropDownList and to
appropriate it to
cmd.Parameters["@dotnet.itags.org.CITY"].Value = DropDownList1.....

I know that it must be something like this above.

Could you help me!

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.cdm is SqlCommand
@.CITY is VARCHAR(20)

Thanks!

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.