小编Bre*_*ton的帖子

SQL和C#中的多个条件参数

考虑以下具有2个可选变量的函数

public List<T> SelectSqlItems<T>(
    string settingsgroup = null,
    int? state = null)
{
    SqlCommand selectCommand = null;

    if (settingsgroup == null)
    {
        selectCommand = new SqlCommand(
            "select * from ApplicationSettings ", con);
    }
    else
    {
        selectCommand = new SqlCommand(
            string.Format(
                "select * from ApplicationSettings where settingsgroup='{0}' ",
                settingsgroup),
            con);
    }

    if (state != null)
    {
        selectCommand.CommandText += 
            !selectCommand
                .CommandText
                .ToLower()
                .Contains("where")
            ? string.Format("where state={0}", state)
            : string.Format("and state={0}", state);
    }

    //etc..
}
Run Code Online (Sandbox Code Playgroud)

我有4种可能性:

settingsgroup==null && state==null
settingsgroup==null && state!=null
settingsgroup!=null …
Run Code Online (Sandbox Code Playgroud)

c# sql

2
推荐指数
1
解决办法
1392
查看次数

在c ++中读取c样式字符串时出错

首先,看看下面的简单代码.

int main(){
    char *name;
    cout << "Enter your name: ";
    cin >> name;
    cout << "Your name is: " << name;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

前面的代码给了我一个错误warning: deprecated conversion from string constant to 'char*'.
但我通过以下方式解决了这个问题:

const char *name;
Run Code Online (Sandbox Code Playgroud)

编译代码后,我有另一个错误no match for 'operator>>' (operand types are 'std::istream {aka std::basic_istream<char>}' and 'const char*').

上一次错误的原因是什么,以及如何解决?

c++

1
推荐指数
1
解决办法
82
查看次数

如何在字符串中插入选项卡?

我真的不明白.请帮忙!

我是初学者.

要标签,你不这样做吗?

/t
Run Code Online (Sandbox Code Playgroud)

无论如何,有人可以向我解释标签吗?谢谢!

c++

0
推荐指数
1
解决办法
2万
查看次数

如何仅使用其中的一些参数调用方法?

我试图将字符串从文本框传递到同一个类中的方法,但是当我尝试这样做时,我收到一条错误消息:

no overload method, TotalWeighting takes one argument.

尽管在我试图发送的方法的参数中包含了每个对象.调用方法的位置出现错误消息.

这是程序的底部:

public void textBox7_TextChanged(object sender, EventArgs e)
{//Assignment 6, box 1
    string STRtb11 = textBox7.Text;//Get value from textBox7 and set to new varaible STRtb10
    TotalWeighting(STRtb11);
}

public void textBox12_TextChanged(object sender, EventArgs e)
{//Assignment 6, box 2
    string STRtb12 = textBox12.Text;//Get value from textBox12 and set to new varaible STRtb11
    TotalWeighting(STRtb12);
}

public static double TotalWeighting(string STRtb1, string STRtb2, string STRtb3, string STRtb4, string STRtb5, string STRtb6, string STRtb7, string STRtb8, string …
Run Code Online (Sandbox Code Playgroud)

c# winforms

0
推荐指数
1
解决办法
82
查看次数

标签 统计

c# ×2

c++ ×2

sql ×1

winforms ×1