According to http://msdn2.microsoft.com/en-us/library/5724t6za(vs.80).aspx...
<article segment>
Visual C# Reference: Errors and Warnings
Compiler Error CS0236
Error Message
A field initializer cannot reference the nonstatic field, method, or property 'field'
Instance fields cannot be used to initialize other instance fields outside of a method. If you are attempting to initialize a variable outside of a method, consider performing the initialization inside the class constructor. For more information, see Methods (C# Programming Guide).
</article segment>
Try this...
<script runat="server">
public void main()
{
string strConn = "Data Source=DANEEL;Initial Catalog=newpubstest;User ID=newstudentmm;Password=studentmm providerName=System.Data.SqlClient";
System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection(strConn);
//create connection string
//create connection query
string strSql = "SELECT * FROM authors";
//create db connection object
}
</script>
Adam Gossage
Lake Wylie, SC, USA
|