[IronPython] How to connect to SQL Server 2008?
Davy Mitchell
daftspaniel at gmail.com
Thu May 27 17:09:15 CEST 2010
>From http://www.ironpython.info/index.php/Accessing_SQL_Server
import clr
clr.AddReference('System.Data')
from System.Data import *
TheConnection =
SqlClient.SqlConnection("server=yourserver;database=News;uid=sa;password=password")
TheConnection.Open()
MyAction = SqlClient.SqlCommand("Select Headline from News", TheConnection)
MyReader = MyAction.ExecuteReader()
while MyReader.Read():
print MyReader[0]
MyReader.Close()
TheConnection.Close()
<http://www.ironpython.info/index.php/Accessing_SQL_Server>Davy
On Thu, May 27, 2010 at 3:54 PM, Matthew Wilson <matt at tplus1.com> wrote:
> I want to connect with IronPython to SQLServer 2008. I found some SAS
> code (SAS is another programming language) that uses OLEDB and I have a
> connection string with the server name and credentials.
>
> In IronPython in Action, there's an example of how to connect to a
> Postgresql database, and that example has this section:
>
> >>> import clr
> >>> clr.AddReference('Npgsql')
> >>> import Npgsql as pgsql
> >>> connection = pgsql.NpgsqlConnection('....')
>
> What do I need to use for my clr.AddReference and my import?
>
> Thanks in advance.
>
> Matt
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
--
--
Davy Stuff - http://daftspaniel.blogspot.com
Geeky Stuff - http://daftpython.blogspot.com
Davy's Ironpython Editor - http://code.google.com/p/davysironpythoneditor/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100527/8c18ae2d/attachment.html>
More information about the Ironpython-users
mailing list