I try this statement in asp net, but receive this alert, can you help me?
thanks in advance.
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.Compiler Error Message: CS0029: Cannot implicitly convert type 'System.Data.Odbc.OdbcConnection' to 'System.Data.SqlClient.SqlConnection'
Source Error:
| Line 42: conn.Open(); Line 43: cmd.CommandText = sSQL; Line 44: cmd.Connection = conn; Line 45: SqlDataReader dr; Line 46: dr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection); |
Gohil JayendrasinhPosted Mar 9, 2012, 8:11 AM
using (OdbcConnection connection = new OdbcConnection(connectionString))
{
OdbcCommand command = new OdbcCommand(queryString, connection);
connection.Open();
// Execute the DataReader and access the data.
OdbcDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine("CustomerID={0}", reader[0]);
}
// Call Close when done reading.
reader.Close();
}
instand of SqlDataReader use OdbcDataReader
please if it's working fine then
check as Accepted Asnwers
Chevy Mark SunderlandPosted Mar 9, 2012, 8:58 AM