Syntax error or something?

MasterGinyu

Newcomer
Joined
Mar 11, 2004
Messages
20
Hey can you guys look at this code. It is really basic but I keep getting a error with it.

Code:
<%@ Page Language="C#"  CodeBehind="index2.aspx.cs" ClassName="index2_aspx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server" >
    <div>
    <center>
        <asp:DataGrid DataKeyField="uid" ID="datagrid1" Runat="Server" Visible=true />
        <br /><br /><br />
        <asp:Button ID="button1" Runat="Server" Text="Push Me" OnClick="myconnection();" />
    </center>
    </div>
    </form>
</body>
</html>

Code:
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: CS1026: ) expected

Source Error:

 

Line 13:         <asp:DataGrid DataKeyField="uid" ID="datagrid1" Runat="Server" Visible=true />
Line 14:         <br /><br /><br />
[COLOR=Red]Line 15:         <asp:Button ID="button1" Runat="Server" Text="Push Me" OnClick="myconnection();" />[/COLOR]
Line 16:     </center>
Line 17:     </div>
 
eramgarden said:
where is your "myconnection" routine?

is it "private sub...."?

Code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySQL.Data;

public partial class index2_aspx
{
    public void myconnection(object sender, EventArgs e)
    {
        DataGrid datagrid1 = new DataGrid();
        MySql.Data.MySqlClient.MySqlConnection oConn = new MySql.Data.MySqlClient.MySqlConnection();
        oConn.ConnectionString = "Data Source=localhost;Database=street***;User ID=pu****;Password=co****;Command Logging=false";
        oConn.Open();
        MySql.Data.MySqlClient.MySqlDataAdapter da = new MySql.Data.MySqlClient.MySqlDataAdapter("select * from user_master", oConn);
        DataSet ds = new DataSet("test");
        da.Fill(ds, "user_master");
        datagrid1.DataSource = ds.DefaultViewManager;
        oConn.Close();
    }

}
 
You can probably remove the OnClick = bit completely, that is not required for a server side event handler - it would be used to call a client side script when the button is clicked.
 
Last edited:
Take out the "();" like this:
<asp:Button ID="button1" Runat="Server" Text="Push Me" OnClick="myconnection" />

----------------------------------------------------------------------
MasterGinyu said:
Hey can you guys look at this code. It is really basic but I keep getting a error with it.

Code:
<%@ Page Language="C#"  CodeBehind="index2.aspx.cs" ClassName="index2_aspx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server" >
    <div>
    <center>
        <asp:DataGrid DataKeyField="uid" ID="datagrid1" Runat="Server" Visible=true />
        <br /><br /><br />
        <asp:Button ID="button1" Runat="Server" Text="Push Me" OnClick="myconnection();" />
    </center>
    </div>
    </form>
</body>
</html>

Code:
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: CS1026: ) expected

Source Error:

 

Line 13:         <asp:DataGrid DataKeyField="uid" ID="datagrid1" Runat="Server" Visible=true />
Line 14:         <br /><br /><br />
[COLOR=Red]Line 15:         <asp:Button ID="button1" Runat="Server" Text="Push Me" OnClick="myconnection();" />[/COLOR]
Line 16:     </center>
Line 17:     </div>
 
Back
Top