[Mono-aspnet-list] databse connectivity issue
setu.sharma
sharma.setu at gmail.com
Fri Jul 31 09:42:13 EDT 2009
hi!!
i have created an ASP.NET application and i need to run it on suse linux
using mono framework but i need to perform databse connectivity on linux
first.i want to use "sqlite" as database.
After creating a sample databse and den creating a C# file which has
connection to this database,when i try to compile and run it it complies
successfully but shows some error while run the".exe" file of compiled C#
file.
Code:
using System;
using System.Data;
using Mono.Data.SqliteClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString = "URI=file:SqliteTest.db";
IDbConnection dbcon;
dbcon = (IDbConnection) new SqliteConnection(connectionString);
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
// requires a table to be created named employee
// with columns firstname and lastname
// such as,
// CREATE TABLE employee (
// firstname varchar(32),
// lastname varchar(32));
string sql =
"SELECT firstname, lastname " +
"FROM employee";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string FirstName = reader.GetString (0);
string LastName = reader.GetString (1);
Console.WriteLine("Name: " +
FirstName + " " + LastName);
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
now after creating the file and compiling it through terminal like: "mcs
TestExample.cs -r:System.Data.dll -r:Mono.Data.SqliteClient.dll" and then
running the .EXE" file og compiled code,it showa an error:
"
Server does not exist or connection refused. --->
Mono.Data.Tds.Protocol.TdsInternalException: Server does not exist or
connection refused. ---> System.Net.Sockets.SocketException: No such host is
known
at System.Net.Dns.GetHostByName (System.String hostName) [0x00000]
at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000]
at Mono.Data.Tds.Protocol.TdsComm..ctor (System.String dataSource, Int32
port, Int32 packetSize, Int32 timeout, TdsVersion tdsVersion) [0x00000]
--- End of inner exception stack trace ---
at Mono.Data.Tds.Protocol.TdsComm..ctor (System.String dataSource, Int32
port, Int32 packetSize, Int32 timeout, TdsVersion tdsVersion) [0x00000]
at Mono.Data.Tds.Protocol.Tds..ctor (System.String dataSource, Int32 port,
Int32 packetSize, Int32 timeout, TdsVersion tdsVersion) [0x00000]
at Mono.Data.Tds.Protocol.Tds70..ctor (System.String server, Int32 port,
Int32 packetSize, Int32 timeout) [0x00000]
at Mono.Data.Tds.Protocol.TdsConnectionPoolManager.CreateConnection
(Mono.Data.Tds.Protocol.TdsConnectionInfo info) [0x00000]
at Mono.Data.Tds.Protocol.TdsConnectionPool.GetConnection () [0x00000]
at System.Data.SqlClient.SqlConnection.Open () [0x00000]
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnection.Open () [0x00000]
at Test.Main (System.String[] args) [0x00000]
"
So i need your help in sorting this out.
Plzz help
--
View this message in context: http://www.nabble.com/databse-connectivity-issue-tp24756660p24756660.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.
More information about the Mono-aspnet-list
mailing list