mercredi 1 août 2018

cant add Jason connection in if statement

i am working on website and i am want upload data to database i had made connection moving throw app.aspx.cs

but there's this below issue is keep showing very time i start the app

Severity    Code    Description Project File    Line    Suppression State
Error   CS0149  Method name expected    PoshaWeb    C:\Users\zatoo\Desktop\Pusha\workweb\PoshaWeb\App.aspx.cs   35  Active

this is my code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Configuration;

namespace PoshaWeb
{
    public partial class App : System.Web.UI.Page
    {   
        protected void Page_Load(object sender, EventArgs e)
        {

            Stream body = Context.Request.InputStream;
            System.Text.Encoding Encoding = Context.Request.ContentEncoding;
            StreamReader reader = new StreamReader(body, Encoding);
            String inJson = reader.ReadToEnd();
            var s = Newtonsoft.Json.JsonConvert.DeserializeObject(inJson);
            System.Data.SqlClient.SqlConnection Conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["MyPoshDB"].ConnectionString);
            Conn.Open();

            System.Data.SqlClient.SqlCommand Comm = new System.Data.SqlClient.SqlCommand
            {
                Connection = Conn
            };
            try
            {
                if (s("type").ToString = "addstudent")
                {
                    Comm.CommandText = "INSERT INTO Members (MemName, MemMobile, MemEmail, MemID, MemGovID, MemDocURL, MemPicURL) VALUES(N'" + s("name").ToString + "', N'"+ s("mobile").ToString + "', N'" + s("email").ToString + "', N'" + s("recordnumber").ToString + "', N'" + s("idnumber").ToString + "', N'" + s("picturepath").ToString + "', N'" + s("documentpath").ToString + "')";
                    Comm.ExecuteNonQuery();
                    Response.Write("{\"result\":\"success\"}");
                }
            }
            catch (Exception ex)
            {
                Page.Response.Write("{\"result\":\"fail\",\"desc\":" + Newtonsoft.Json.JsonConvert.SerializeObject(ex.Message) + "}");
            }
            Conn.Close();
        }

    }
}

i am still have problem that var S not working inside {if} please help

Aucun commentaire:

Enregistrer un commentaire