在我的代码中,我这样启动了Datetime
DateTime myDate;
Run Code Online (Sandbox Code Playgroud)
但是当我尝试访问它时,我得到了这个错误.
在访问之前,可能不会初始化局部变量'myDate'
在这里我初步了解我的约会知道吗?
我已经写了一个代码来创建和写一个文件.但是它没有创建一个文件.没有任何编译错误.我的文件夹层次结构是DesktopModules - > SMSFunction-> SMSText.我需要在SMSText文件夹中创建一个文本文件,
public void WriteToFile( string source, int dest, string messageIn, string operatorNew)
{
try{
string directory = ResolveUrl("~/DesktopModules/SMSFunction/SMSText");
//string directory = Server.MapPath("~/DesktopModules/SMSFunction/SMSText");
string filename = String.Format("{0:yyyy-MM-dd}__{1}.txt", DateTime.Now);
string path = Path.Combine(directory, filename);
if (!File.Exists(filename))
{
using (StreamWriter str = File.CreateText(path))
{
str.WriteLine("msisdn: " + source);
str.WriteLine("shortcode : " + dest);
str.WriteLine("Message : " + messageIn);
str.WriteLine("Operator :" + operatorNew);
str.Flush();
}
}
else if (File.Exists(filename))
{
using (var str = new StreamWriter(filename))
{
str.WriteLine("msisdn: " + …Run Code Online (Sandbox Code Playgroud) 我有这样的字符串
<tr> <td> 14.54.49 </ td> <td> SKUTTELG </ td> <td> 001772377777 </ td> <td> test </ td> <td> SKUTTELG - mottatt.Vilt:Okse2,5år+ Jak </ td> </ tr>
我想得到
SKUUTELG 001772377777测试SKUTTELG - mottatt.Vilt:Okse2,5år+ Jak
需要删除
<TR> <TD>
我试试这样......
var testString = "MY STRING"
var stringArray = testString.Split('<tr><td>');
stringArray.Remove("<tr><td>);
var output = String.Join("<tr><td>", stringArray);
Run Code Online (Sandbox Code Playgroud)
但这不起作用..
我想检查用户是否有效.我给了我一个例外,当用户有效时它没有问题,但是如果用户无效则有一些问题.
例外情况是:位置0没有行
这是代码的一部分,
public bool CheckUserExistAndReporter(string user)
{
int reporterDnnId = -1;
SMSFunctionController mysms = new SMSFunctionController();
DataSet uds = mysms.GetUsersUnitByUserName(user);
reporterDnnId = Convert.ToInt32(uds.Tables[0].Rows[0]["DnnUserID"]);
if (reporterDnnId > 0)
{
bool isValidUser = true;
return isValidUser;
}
//else
//{
//bool isValidUser =false;
//return isValidUser;
// }
return false;
}
Run Code Online (Sandbox Code Playgroud)
然后我在这里打电话给那个人.
if (!CheckUserExistAndReporter(user))
{
ErrorLog(messageIn);
msgOut = "ugyldig Bruker";//Invalid User.
}
Run Code Online (Sandbox Code Playgroud)
什么是错误?
基本上当我注册(注册详细信息转到登录表)时,此数据将转到2个表:
使用@Attrib我检查哪些数据需要转到哪个表.但是我在第一else部分附近遇到错误.
错误是:
期待SELECT或''(''的'@Attrib'附近的语法不正确
这是代码:
ALTER procedure [dbo].[Registration_SP]
(
@Email varchar(50),
@Password varchar(50),
@Repassword varchar(50),
@Attrib varchar(50)
)
AS
BEGIN
Insert into Login (Email,Password,Repassword,Attrib)
values(@Email,@Password,@Repassword,@Attrib)
IF (@Attrib = 'Student')
BEGIN
Insert into StudentReg
(StudentId,FirstName,LastName,Gender,Address1,Address2,Address3,
LandPhone,MobilePhone,Budget,IsFinancialSupport,CourseName,
IsJobSeeker,Country,Region,IsSupportActive,RegDate,ImagePath,
ShortCode)
Values(@Email,'','','','','','','','','','','','','','','','','','')
END
ELSE (@Attrib = 'Financial Supporter')
BEGIN
Insert into SupporterReg
(SupporterId,SupporterName,University,ContactNo,StudentLocation,RegDate,
ImagePath,ShortCode)
Values(@Email,'','','','','','','')
END
Run Code Online (Sandbox Code Playgroud)
进一步澄清,我已经附上了下图:

我有一个代码如下所示.
我从查询字符串中获取消息.在那之后,我将把它传达给消息array(msg_arr).但是所有这些东西都在里面Page_load.
但为什么这个错误表明了?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string messageIn = Request.QueryString["msg"];
// some code here
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
string[] msg_arr = messageIn.Split(' '); // error shown here
int size = msg_arr.Length;
if(!CheckUserExistAndReporter("messageIn"))
{
// Response.Redirect("~/test.aspx");
}
else
{
Run Code Online (Sandbox Code Playgroud)