INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Pervasive SQL v12 with Visual Basic .NET

Pervasive SQL v12 with Visual Basic .NET

(OP)
Hello, all. I am fairly new to both Visual Basic .NET and Pervasive SQL. I Was wondering if anyone could give me a rundown on how to conduct a SELECT statement and insert the result (it will be a single result) into a VB.net Variable. Thanks!

RE: Pervasive SQL v12 with Visual Basic .NET

Here are the basic steps:
1. Create (or verify) a PSQL database exists for the data you intend to access.
2. Add a reference to the Pervasive.Data.SqlClient.DLL to your VB.NET project.
3. Use the PsqlConnection to open a connection to the PSQL database.
4. Use PsqlCommand to execute the SQL (SELECT) statement.
5. Read the resultset using a PsqlDataReader and save the value to your variable.

Here's a simple C# app from many years ago that I posted. I'm looking for VB.NET.

CODE --> C#

using System;
using System.Data;
using Pervasive.Data.SqlClient;
using System.IO;

namespace SimpleADONetTest
{
	class Class1
	{
		[STAThread]
		static void Main(string[] args)
		{
			try
			{
				PsqlConnection conn=new PsqlConnection("ServerDSN=demodata;UID=;PWD=;Server=localhost;");
				conn.Open();
				Console.WriteLine("ServerName: " + conn.ServerName.ToString());
				Console.WriteLine("ServerDSN: " + conn.ServerDSN.ToString());
				// Create a SQL command
				string strSQL = "select * from class";
				PsqlCommand DBCmd = new PsqlCommand(strSQL, conn);
				PsqlDataReader myDataReader;
				myDataReader = DBCmd.ExecuteReader();
				Console.WriteLine("FieldCount: " + myDataReader.FieldCount.ToString());
				while (myDataReader.Read())
				{
					for (int i=0;i<myDataReader.FieldCount;i++)
					{
						Console.WriteLine("Field " + i.ToString() + ": " + myDataReader[i].ToString());
					}
				}
				myDataReader.Close();
				conn.Close();
				Console.WriteLine("Press Enter to continue");
				Console.ReadLine();
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.Message);
				Console.ReadLine();
			}
			
		}
	}
} 

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close