Current location: Hot Scripts Forums » Programming Languages » ASP.NET » how to extract info from a table


how to extract info from a table

Reply
  #1 (permalink)  
Old 02-04-04, 11:27 AM
Cat_FYP Cat_FYP is offline
New Member
 
Join Date: Feb 2004
Location: Ireland
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
how to extract info from a table

heya,

To anyone that can help, I would be eternally grateful!!
I need to extract information from a table in a database using ASP.Net and VB script. So far, I have tried

dim intNumber

int (intNumber)

objectConn.Open()

intNumber = (int) cmd.ExecuteScalar();
'number = cByte (cmd.ExecuteScalar())

objConn.Close()

but I keep getting an error saying that int can't handle that number of arguments. I've tried loads of things but keep ending back where I started.
I need to extract a specific column from a table in my database and then convert that to a string if possible.

Help please!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-08-04, 01:44 AM
Shane Shane is offline
Coding Addict
 
Join Date: Jun 2003
Location: Maryland, US
Posts: 268
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
'//Import namespaces
using System.Data;
using System.Data.SqlClient;
 
// main code
// create connection object. This is used to store your connection.
SqlConnection conn = new SqlConnection("CONNECTION STRING HERE");
 
// create command object. This object contains sql command info.
SqlCommand cmd = new SqlCommand("select number from table",conn);
 
int number;
 
// open the connection
conn.Open();
 
// execute scalar and return one value. If you're trying to return
// more than one record, then use the SqlDataReader, not the scalar.
number = Convert.ToInt32(cmd.ExecuteScalar());
 
// close
conn.Close();

Quote:
Originally Posted by Cat_FYP
heya,

To anyone that can help, I would be eternally grateful!!
I need to extract information from a table in a database using ASP.Net and VB script. So far, I have tried

dim intNumber

int (intNumber)

objectConn.Open()

intNumber = (int) cmd.ExecuteScalar();
'number = cByte (cmd.ExecuteScalar())

objConn.Close()

but I keep getting an error saying that int can't handle that number of arguments. I've tried loads of things but keep ending back where I started.
I need to extract a specific column from a table in my database and then convert that to a string if possible.

Help please!!
__________________
Shane Bauer
Microsoft Certified Professional (MCP) - ASP.NET
ASP/ASP.net, C#, VB/VB.NET, PHP, Perl, SQL
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-09-04, 05:33 AM
Cat_FYP Cat_FYP is offline
New Member
 
Join Date: Feb 2004
Location: Ireland
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Smile

Thanks for the help. Much appreciated!!

Quote:
Originally Posted by Shane
Code:
'//Import namespaces
using System.Data;
using System.Data.SqlClient;
 
// main code
// create connection object. This is used to store your connection.
SqlConnection conn = new SqlConnection("CONNECTION STRING HERE");
 
// create command object. This object contains sql command info.
SqlCommand cmd = new SqlCommand("select number from table",conn);
 
int number;
 
// open the connection
conn.Open();
 
// execute scalar and return one value. If you're trying to return
// more than one record, then use the SqlDataReader, not the scalar.
number = Convert.ToInt32(cmd.ExecuteScalar());
 
// close
conn.Close();
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
auto table resize derick_2k JavaScript 4 04-26-04 03:32 PM
reading info from a file (csv / xls) and displaying info lordmerlin PHP 7 03-20-04 04:39 PM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 05:28 PM
strange grey "extra" table area... skyraider HTML/XHTML/XML 1 12-10-03 11:55 PM
moving data from table to table ..please help! geneane ASP 2 09-22-03 08:02 PM


All times are GMT -5. The time now is 06:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.