我是C#的初学者,当我执行代码时,会出现以下错误消息:
“发生了'System.Data.SqlClient.SqlException'类型的异常 System.Data.dll但未在用户代码中处理
其他信息:'b'附近的语法不正确
我的代码:
const webpack = require('webpack');
const path = require('path');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const PATHS = {
app: path.join(__dirname, 'resources/assets/js'),
publicPath: path.join(__dirname, 'public')
};
module.exports = {
entry: [
"webpack-dev-server/client?http://localhost:4444",
"webpack/hot/dev-server",
PATHS.app
],
output: {
path: PATHS.publicPath,
publicPath: '/js/',
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: "react-hot",
exclude: /node_modules/
},
{
test: /\.jsx?$/,
include: PATHS.app,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0', 'react-hmre'], // set of plugins out of the box
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy']
}
}
]
},
devtool: 'eval-source-map',
devServer: {
contentBase: PATHS.publicPath,
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
noInfo: false,
stats: 'errors-only',
host: process.env.HOST,
port: 4444,
proxy: {
"/api/*": "http://127.0.0.1:8000/"
}
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new NpmInstallPlugin({
save: true
})
]
};
我的数据库有三个表:
public void populateIngredients()
{
string query = "select a.Name from Ingredients a" +
"inner join RecipeIngredient b ON a.Id = b.IngredientID" +
"where b.RecipeID = @RecipeID";
using (con = new SqlConnection(connection))
using (SqlCommand cmd = new SqlCommand(query,con))
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
cmd.Parameters.AddWithValue("@RecipeID", listRecipes.SelectedValue);
DataTable IngredientTable = new DataTable();
sda.Fill(IngredientTable); // The error points here
listIngredients.DisplayMember = "Name";
listIngredients.ValueMember = "Id";
listIngredients.DataSource = IngredientTable;
}
}
(身份证,姓名,准备时间,说明)Recipe
(身份证,姓名)Ingredients
(Id,RecipeID,IngredientID)答案 0 :(得分:0)
缺少某些单词之间的空格!
放一个空间" "每个字符串常量的第一个。
你的字符串查询现在是这样的:
"select a.Name from Ingredients ainner join RecipeIngredient b ON a.Id = b.IngredientID" +
且a
和inner
字之间没有空格。