"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OT*************@TK2MSFTNGP03.phx.gbl...
I've used connectionstrings like this one for my webproject:
connectionString="Server=Pdc1;Database=Testing;Int egrated
Security=false;User ID=tester;Pwd=hardtoguesspwd;" />
But now I need to change to using ODBC as the webhosting company only
support ODBC.
Are you absolutely sure about that? Any ISP which supports ASP.NET 2.0 and
above and also supports SQL Server will almost certainly support
SqlConnection - it's difficult to imagine how they couldn't, as it's built
directly into the .NET Framework. For an ISP to support *only* ODBC these
days is almost unthinkable - do they still have any clients left? I would
check again, if I were you...
If it turns out that they do support only ODBC, then I would seriously
consider finding another ISP ASAP, as they clearly haven't a clue what
they're doing. Which ISP is it, AAMOI? Don't tell me it's GoDaddy...?
So from my understanding I need to change my connectionstring - specify
what ODBC profile to use.
Not necessarily - there are quite a few ways of using ODBC:
http://www.connectionstrings.com/?carrier=sqlserver2005
In addition I wonder if I need to change my code for accessing the
database:
You definitely do.
public List<CarGetCars()
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("test_spGetCars", cn);
cmd.CommandType = CommandType.StoredProcedure;
cn.Open();
return GetCarCollectionFromReader(cmd.ExecuteReader());
}
}
(Does that code looks okay for being used together with ODBC?)
No. The above code is using SqlConnection, i.e. the native .NET data
provider for SQL Server, which is what you should be using in an ideal
world.
If you absolutely must use ODBC, then you'll need to use the ODBC provider
objects e.g. OdbcConnection, OdbcCommand etc...
Any suggestions?
Move to a real ISP.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net