C # Connect SQLServer code

zhaozj2021-02-16  72

String connStr = "PERSIST security info = true; user ID = sa; password = tonhe; initial catalog = mynotebook; data source = localhost;";

String sqlstr = "Insert Notebook (Subject, Href, Content, Type) VALUES ('" txtsubject.text ",'" txthref.text ", '" txtcontent.text "," i ")" ;

SQLCONN = New SqlConnection (connStr);

Sqlconn.open ();

Sqlcmd = new sqlcommand ();

Sqlcmd.connection = sqlconn;

Sqlcmd.commandtext = SQLSTR;

Sqlcmd.executenon query ();

Sqlcmd.dispose ();

Sqlconn.close ();

转载请注明原文地址:https://www.9cbs.com/read-14988.html

New Post(0)