Jump to content
Sign in to follow this  
the cracker

Aku Ade Error Ni La.. Sape Leh Tlong?

Recommended Posts

ni coding aku...

using System;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

using System.Collections;

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;

public partial class createUser : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void subButton_Click(object sender, EventArgs e)

{

String connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

SqlConnection connection = new SqlConnection(connectionString);

SqlCommand cmd = new SqlCommand(@"INSERT INTO loginData(UserId,staffName,staffDepartment,staffEmail)

VALUES(@UserId,@staffName,@staffDepartment,@staffEmail)", connection);

cmd.Parameters.Add("@UserId", SqlDbType.UniqueIdentifier).Value = usernameText.Text;

cmd.Parameters.Add("@staffName", SqlDbType.NVarChar, 50).Value = nameText.Text;

cmd.Parameters.Add("@staffDepartment", SqlDbType.NVarChar, 50).Value = deptText.Text;

cmd.Parameters.Add("@staffEmail", SqlDbType.NVarChar, 50).Value = emailText.Text;

connection.Open();

int i = cmd.ExecuteNonQuery();

connection.Close();

}

}

dpt error ni bile run..

System.InvalidCastException: Invalid cast from 'System.String' to 'Sy

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...