我是c#的初学者,当我执行代码时出现此错误消息>>
"System.Data.dll中出现'System.Data.SqlClient.SqlException'类型的异常,但未在用户代码中处理
附加信息:'='附近的语法不正确."
这是代码!!
string position;
SqlConnection con = new SqlConnection("server=free-pc\\FATMAH; Integrated Security=True; database=Workflow; ");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT EmpName FROM Employee WHERE EmpID=" + id.Text, con);
SqlDataReader Read = cmd.ExecuteReader();
if (Read.Read()==true)
{
position = Read[0].ToString();
Response.Write("User Registration successful");
}
else
{
Console.WriteLine("No Employee found.");
}
Read.Close();
Run Code Online (Sandbox Code Playgroud) 我想发送一封带有超链接的电子邮件,我尝试发送没有链接的电子邮件,但是当我添加链接时,它会出错
这是代码:
MailMessage o = new MailMessage("f@hotmail.com", "f@hotmail.com", "KAUH Account Activation", "Hello, " + name + "\n Your KAUH Account about to activate click the link below to complete the actination process \n "+<a href=\"http://localhost:49496/Activated.aspx">login</a>);
NetworkCredential netCred = new NetworkCredential("f@hotmail.com", "****");
SmtpClient smtpobj = new SmtpClient("smtp.live.com", 587);
smtpobj.EnableSsl = true;
smtpobj.Credentials = netCred;
smtpobj.Send(o);
Run Code Online (Sandbox Code Playgroud) 我正在使用SQL Server 2008,我使用Microsoft SQL Server Management Studio创建了数据库和表.
每当我在列或插入的记录中进行任何更改时,它都会显示一条警告消息,说"不允许保存更改......."
我非常需要你的帮助<3
谢谢
我正在使用ASP.NET开发一个网站.
当我开始编写代码时,我没有设计视图来设计网站(请参阅下面的链接中的屏幕截图).我真的需要帮助.
http://www.4shared.com/download/CZTzYSUu/18-09-34_06-13-06_.png?tsid=20130726-032036-c925f200
我是c#的新开发人员,我创建了ac #project,我需要访问SQL数据库来执行SELECT语句
我在这个图中得到了这个错误
我的连接声明是正确的,所以它有什么问题?!
我尝试了提到的解决方案,我得到了这个错误
有谁知道如何处理它?
我包括using System.Windows;
但是线程仍然存在于命名空间中?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Net.Mail;
using System.Net;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows;
using System.Timers;
using Graduation_Project;
namespace GP
{
public partial class Register : System.Web.UI.Page
{
static int count = 0;
static int timer = 600;
protected void Page_Load(object sender, EventArgs e)
{
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
dt.Interval = new TimeSpan(0, 0, 0, 0, 600000); // 600000 …
Run Code Online (Sandbox Code Playgroud) 我不知道它的问题是什么?我试图解决它,但我没有得到任何结果!
我的浏览器链接
http://localhost:49496/Activated.aspx?id=2
Run Code Online (Sandbox Code Playgroud)
而代码是
string uri = HttpContext.Current.Request.Url.AbsoluteUri;
int num1 = uri.IndexOf('=');
int num2=uri.Length-1;
string ID = uri.Substring(num1,num2);
Run Code Online (Sandbox Code Playgroud)
错误说:
索引和长度必须指向字符串中的位置.参数名称:长度
那么,它有什么问题?!