Reading A Result From A Database To A String?

Feb 22, 2010

I have a database (SQLExpress) to populate my web page with some products.

Some times, I want to perform an if else function to the result (which seems to be very difficult in asp.net for some reason - compared to asp.classic).

The code works fine

string PN = (Convert.ToString(ds.Tables["B2B"].Rows[0]["PartNumber"]));

Is there a better way to do this? Or is this the correct way?

Second question is:

ds.Tables["B2B"].Rows.Count;

also works. correct my terminology but the ds parameters(?) Tables, Rows and Count all belong to ds. How does any one know this? How would I know what else I can use with ds? I have viewed the microsoft website to try to work out what I can and can't apply and have gotten no where! Is there a site which says if you use XX, then you can use the following parameters.

View 1 Replies


Similar Messages:

Inconsistent Result While Reading Collections From Web.Config?

Oct 21, 2010

Is there a reason why i get different result when reading collections using WebConfigurationManager.GetSection method.

It sometimes returns values correctly in the Hashtable and at other times returns nothing for the same data. Its inconsistent.

client:-

Hashtable hsh = (Hashtable)WebConfigurationManager.GetSection("test1");

Config:-

<section
name="test1"
type="System.Configuration.DictionarySectionHandler"
/>
<section
name="test2"
type="System.Configuration.DictionarySectionHandler"
/>.......

View 1 Replies

Web Forms :: Reading Name Or String?

Mar 30, 2010

I m reading different names. My problem is

1) Name shouldnot begin with hyphen or Apostrophe.ex: 'john or -john , both are errors

2) Name should not contain hyphen+Apostrophe or Apostrophe+hyphenEx: O'Brain is correct and O'-Brain is wrong.

3) Name should not contain space+Apostrophe or Apostrophe+Space Ex: O 'Brain and O' Brain , both are wrong. but Billy-Bob is correct

4) Name should not contains Hyphone+space or space+Hyphen. Ex: O- Brain and O -Brains, both are wrong

View 2 Replies

Connection String Reading Data From Excel?

May 18, 2010

I am trying to read data from excel file in asp.net. I have added the connection string to webConfig file:

<add name="xls" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=HPM_DB.xls;Extended Properties=Excel 8.0"/>

But it shows me an errormessage when I run this query:

string query = "Select * from [IO_Definition$]";

IO_Definition is the name of the spreadsheet in my excel file. I also added the excel file to the App_Data folder of the website.

The error is:

The Microsoft Jet database engine could not find the object 'IO_Definition$'. Make sure the object exists and that you spell its name and the path name correctly.

The thing is, when I write the absolute path of the excel file in the connectionString it does work. Is there anyway I can make it work without writing the absolute path?

View 1 Replies

Obtaining String Result From Other Website Inquiry?

Mar 11, 2010

I have an ASP.net/VB.net website, and want to make an inquiry of another website to obtain particular information for use on my site in string format. For example, I have used the code:

Result01 = "http://api.hostip.info/get_html.php?ip=" + Variable01

which only produces the other website address as a string. However, I want to get the actual result of the inquiry as a string. I have experimented with System.Xml.XmlDocument coding, without any luck. the proper coding to get the results of such an inquiry as a string?

View 6 Replies

How To Get The Result Of An Action (html) In A String Variable

Dec 13, 2010

is it possible to get the result of an action into a string variable

I need something like this:

public ActionResult Do()
{
var s = this.Index().GetStringResult();
...
}

View 2 Replies

Reading CSV File With OLEDB Ignores First Line Even With HDR=No In Connection String?

Jan 4, 2011

We're converting a Classic ASP site to an ASP.NET site. One function was to upload a 'template' of data in CSV format for importing into the database. There were several different record types in there (the first field always indentifies the type of data).

The task was to get the CSV into a DataTable so it could be validated (new project is to have MUCH better validation rules)

The code seemed pretty straightforward - watered down (taking out comments, Try/Catch, etc) it is as follows:

Dim da As New System.Data.OleDb.OleDbDataAdapter
Dim cn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDirectory & ";" & "Extended Properties=""Text;HDR=No;FMT=Delimited;""")
Dim cd As New System.Data.OleDb.OleDbCommand("SELECT * FROM " & strCSVFilename, cn)
cn.Open()
da.SelectCommand = cd
da.Fill(dtData)

The DataTable (dtData) is populated, but only starting with the second line of the CSV file DESPITE the fact that "HDR=No" is in the connection string. What am I missing here?

View 1 Replies

C# - How To Encrypt String In Which Result Are Letters Or Numbers Only Without Any Other Character

Aug 21, 2010

I use some code to encrypt & decrypt string in C# but i want a good one that can generate encrypted string that contain only letters or numbers not any other ( + , / , ...)

View 1 Replies

C# - Can Execute An Aspx File In A Class Library And Get The Result As A String

Feb 19, 2010

I have an c# Class Library where I need some dynamic template based text. Instead of inventing my own template parser I thought I could create an aspx file in my project that is executed at runtime and, instead of viewing the output in a browser, I want a StreamReader or string object that holds the result.

View 3 Replies

Pros/cons Of Reading Connection String From Physical File Versus Application Object

Apr 9, 2010

my ASP.NET application reads an xml file to determine which environment it's currently in (e.g. local, development, production).

It checks this file every single time it opens a connection to the database, in order to know which connection string to grab from the Application Settings.

I'm entering a phase of development where efficiency is becoming a concern. I don't think it's a good idea to have to read a file on a physical disk ever single time I wish to access the database (very often).

I was considering storing the connection string in Application["ConnectionString"].

[code].....

I didn't design the application so I figure there must have been a reason for reading the xml file every time (to change settings while the application runs?) I have very little concept of the inner workings here. What are the pros and cons?

View 2 Replies

WCF / ASMX :: The Maximum String Content Length Quota (8192) Has Been Exceeded While Reading XML Data

Dec 21, 2010

i am implementing the wcf webservice and using in my web application.

I am getting the error maximum string content length quota (8192) has been exceeded while reading XML data.

client side code :

[Code]....

WCF web.config

[Code]....

View 4 Replies

Forms Data Controls :: Returning Single String Result Through Stored Procedure

Jun 22, 2010

I am trying to return single string result through a stored procedure and Linq. This works fine when I test the stored procedure but it is not returning the value to the page. The value returned is always 0 which is the return value. This is the stored procedure:

ALTER PROCEDURE Login
@CustomerName nvarchar(50),
@Password nvarchar(50) output
As
Select @Password=Password
From Customers
Where Customers.CustomerName=@CustomerName

This is the vb
ALTER PROCEDURE Login
@CustomerName nvarchar(50),
@Password nvarchar(50) output
As
Select @Password=Password
From Customers
Where Customers.CustomerName=@CustomerName is the code created by the designer

This is the designer function
<FunctionAttribute(Name:="dbo.Login")> _
Public Function Login(<Parameter(Name:="CustomerName", DbType:="NVarChar(50)")> ByVal customerName

As String, <Parameter(Name:="Password", DbType:="NVarChar(50)")> ByRef password As String) As IntegerDim result
As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), customerName, password)
password = CType(result.GetParameterValue(1),String)
End Function

View 4 Replies

C# - Reading Images From A Database And Outputting?

Mar 28, 2011

I have images stored in my database table and looking to read from the database and output these images in my asp.net page.

View 3 Replies

Reading File And Store In Database?

Mar 9, 2010

I m reading a text file. After reading all the lines, I want to insert those records into respective fields in database.

So how to store the 1 or 2 or 3 or 4 or 5 lines of records until I read the last record.?

[code]....

first 9 number is emp id, next is name and next is salary.

While I m reading, I can store only last record. How to store all the records in a array to store in the database after reading all the lines.

View 12 Replies

Reading A .csv File And Outputting Data To Database?

Jan 25, 2011

I have a csv file with 5 columns. I need to read this file using c# and have to write the contents to the table in database which has 5 columns to it.

if anyone know the code or steps to do this.

View 8 Replies

Web Forms :: Reading From Database Without Using Templated Controls?

Mar 13, 2011

I want to read from database without using templated control like gridview, listview ...etc I am being able to read from db, but shows only the first row;

My .aspx pgae is;
<div>
<asp:DropDownList
ID="ddlCustomer"
runat="server"
AutoPostBack="false"
OnSelectedIndexChanged="ddlCustomer_SelectedIndexChanged"
DataTextField="CustomerName"
DataValueField="CustomerID">
</asp:DropDownList>
<div>
<asp:Button ID="btnGetCustomers" runat="server" Text="Button" OnClick="btnGetCustomers_Click" />
</div>
<div>
<asp:Label ID="lblOrderDate" runat="Server" style="border:1px solid #ccc;" width="100"/>
<asp:Label ID="lblOrderName" runat="Server" style="border:1px solid #ccc;" width="100"/><br />
</div>

and code-behind;

[Code]....

View 5 Replies

Web Forms :: Reading And Posting A .csv File Into A SQL Database

Jul 13, 2010

I have the following data that basically I only need a few bits of information from: The only things I need from this are:

Patients Name
Drs Name
Patients Phone Number
Appt Time
Appt Date

and the rest of the information I can discard. A customer uploads this as a .csv file (even though it really isn't as you can see) and I'd like to parse the needed information and post that to my SQL database and discard the rest. I think I can do this with a dataset but I've never built that before. The fields from the customer will always be the same and the fields I will need will always be the same. Also, the date time has to be in the format of yyyy/mm/dd:hhmm and the phone number always has to have 512 as a prefix. Here is the code I currently have for my site:

[Code]....

View 30 Replies

SQL Server :: Reading Data From .CSV File Into Sql Database

Jul 15, 2010

I urgently need to find a way of reading data from a .CSV or .xls(Excel) file into an sql database so that I can use it in my asp.net 2.0 application.

View 4 Replies

DataSource Controls :: Reading Information From Database?

May 16, 2010

I would like to check my database for to see if a user name is available but my script isn't working.

I am taking input from a text box call unametextbox and i'm trying to extract any matching username from the database, this is my code.

[Code]....

View 8 Replies

WCF / ASMX :: Reading Data From Database Using Web Service

Apr 25, 2010

I have a requirement in which i have a database table which has 4 columns Id,Name,position,city.....now i have a form in which the user will be filling in the id and then the other three columns should auto populate ....now i want a web service which will make a data connection and get the Id from the form and then query the database and get the other three columns..i am pretty new to web services ..can somebody give me some heads up on how to achieve this...let me know if i have to provide more details.

View 8 Replies

Databases :: Reading Excel Data To SQL Database

Sep 23, 2010

Using C# to develop an application.I need to upload data ( which is in excel) to a sql table.

[Code]....

View 1 Replies

Loop Database Result In Groups?

Apr 2, 2010

I have a query that returns a pretty big result. I want to break the big set into several smaller sets to pass into a function. If i had a 100 records returned, how would i get 10 datasets?

View 1 Replies

Reading - Parsing And Posting Data From A .csv File Into A SQL Database

Jul 13, 2010

I have the following data that basically I only need a few bits of information from:

Resource:X - Y;Z - Å;Type:(all) From Date:
07/12/2010 - To Date 07/12/2010 Sort
by:Time Include Referring
source/physician:No Footer:Default
Criteria:None
","Appointments","X,
Y","ZAssociates","Monday, July 12,
2010","Time","Patient Name","Patient
ID","Appt. Type","Ref. Source/
Physician","Phone","Type","DOB
","Z, X","Y","7/12/2010
12:00:00AM","Time","Patient
Name","Patient ID","Appt.
Type","Phone","Type","DOB "," 7:30
[snip]

The only things I need from this are:

Patients Name
Drs Name
Patients Phone Number
Appt Time
Appt Date

and the rest of the information I can discard. A customer uploads this as a .csv file (even though it really isn't as you can see) and I'd like to parse the needed information and post that to my SQL database and discard the rest. I think I can do this with a dataset but I've never built that before. The fields from the customer will always be the same and the fields I will need will always be the same. Also, the date time has to be in the format of yyyy/mm/dd:hhmm and the phone number always has to have 512 as a prefix. Here is the code I currently have for my site:

Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Submit1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim SaveLocation = "\xxxWEB3wwwrootWebfile1RemindersDoug_Ancildoug.csv"
If UploadFile(SaveLocation) Then
'the file was uploaded: now try saving it to the database
SaveToDatabase(SaveLocation)
End If
End Sub
Private Function UploadFile(ByVal SavePath As String) As Boolean
Dim fileWasUploaded As Boolean = False 'indicates whether or not the file was uploaded
'Checking if the file upload control contains a file
If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
Try
'checking if it was .txt file BEFORE UPLOADING IT!
'You used to upload it first...but the file could be a virus
If File1.FileName = ("doug.csv") = False Then
'The file is not the expected type...do not upload it
'just post the validation message
message.Text = "Sorry, thats not the correct file."
message2.Text = "Please locate and upload 'doug.csv'"
Else
'The file is a .txt file
'checking to see if the file exists already
'If it does exist Deleting the existing one so that the new one can be created
If IO.File.Exists(SavePath) Then
IO.File.Delete(SavePath)
End If
'Now upload the file (save it to your server)
File1.PostedFile.SaveAs(SavePath)
'After saving it check to see if it exists
If File.Exists(SavePath) Then
'Upload was sucessful
message.Text = "Thank you for your submission."
fileWasUploaded = True
Else
'the file was not saved
message.Text = "Unable to save the file."
End If
End If
Catch Exc As Exception
'We encountered a problem
message.Text = "Your file was not in the correct format. Please contact Customer Service at xxxx-xxxx-xxxx."
End Try
Else
'No file was selected for uploading
message.Text = "Please select a file to upload."
End If
Return fileWasUploaded
End Function
Private Sub SaveToDatabase(ByVal SavePath As String)
Try
Dim sqlQueryText As String = _
"BULK INSERT dialerresults " + _
"FROM '" & SavePath & "' " + _
"WITH ( FIELDTERMINATOR = ',' , ROWTERMINATOR = '
' )"
' and bulk import the data:
'If ConfigurationManager.ConnectionStrings("Dialerresults") IsNot Nothing Then
'Dim connection As String = ConfigurationManager.ConnectionStrings("Dialerresults").ConnectionString
Dim connection As String = "data source=10.2.1.40;initial catalog=IVRDialer;uid=xxxx;password=xxxxx;"
Using con As New SqlConnection(connection)
con.Open()
' execute the bulk import
Using cmd As New SqlCommand(sqlQueryText, con)
cmd.ExecuteNonQuery()
End Using
End Using
'Else
'message.Text="ConfigurationManager.ConnectionStrings('Dialerresults') is Nothing!"
'End If
Catch ex As Exception
message.Text = "Your file was not in the correct format. Please contact Customer Service at xxxxxxx."
End Try
End Sub
End Class

View 1 Replies

Web Forms :: Reading Webparts Custom Properties From Database?

Jan 19, 2010

we are working on some utilities to provide the webmaster, one of which needs to search the properties of the webparts on a page for certain string values. So I want to desterilize the blob into the object graph and
iterate through the properties.

View 1 Replies

Web Forms :: Create Text File While Reading From Database?

Oct 1, 2010

How to create Text file while reading from database?

DataBase Table has 10 records in it
ID Name Age
1 Jon 18
2 Martin 20
..
..
10 Andy 30

I want create a text file like this

ID: 1
Name: Jon
Age: 18
-----------------
ID: 2
Name: Martin
Age: 20
-----------------
ID: 10
Name: Andy
Age: 30

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved