在SQL数据库中搜索(C#UWP)

时间:2016-08-08 16:37:57

标签: c# mysql visual-studio uwp

我是开发Windows 10的新手。 我有客户数据库。

我像这样连接到它

{
    "la": {
        "tonoMayor": "A",
        "tonoMenor": "Am",
        "septima": "A7",
        "sexta": "A6",
        "menorSexta": "Am6",
        "menorSeptima": "Am7",
        "septimaMayor": "A7M",
        "disminuida": "Adim7",
        "aumentados": "Aaug"
    },
    "la#Sib": {
        "tonoMayor": "la#",
        "tonoMenor": "A#m",
        "septima": "A#m",
        "sexta": "A#6",
        "menorSexta": "A#m6",
        "menorSeptima": "A#m7",
        "septimaMayor": "A#7m",
        "disminuida": "A#dim7",
        "aumentados": "A#aug"
    }
}

如果我找到他,我想通过他的电话搜索客户,我需要将有关此客户的所有信息写入控制台。

表中包含以下字段:id,name,mob,adress,birthday,email。

我需要通过mob进行搜索。我尝试使用此查询

import React, { Component } from 'react'
import { Router, Route, Link, IndexRoute, hashHistory, browserHistory, DefaultRoute, IndexLink } from 'react-router'
import Data from '!json!../json/acordes.json';

class App extends Component {
  render () {
    return (
      <Router history={hashHistory}>
        <Route path='/' component={Container}>
          <IndexRoute component={Home} />
          <Route path='/acordes' component={Acordes}>
            <IndexRoute component={La} />
            <Route path='laSib' component={LaSib} />
            <Route path='query' component={Query} />
          </Route>
          <Route path='/about(/:name)' component={About} />
          <Route path='/namedComponent' component={NamedComponents}>
            <IndexRoute components={{ title: Title, subTitle: SubTitle }} />
          </Route>
          <Route path='*' component={NotFound} />
        </Route>
      </Router>
    )
  }
}

如何将此客户的所有字段显示到控制台?

感谢您的帮助。

已更新

点击搜索按钮

时也会出现此错误
using (MySqlConnection connection = new MySqlConnection("Database= milanoold_db;Data Source=144.76.133.122;User Id=milanoold_u;Password=sK5PvCDP; SslMode=None; CharSet=utf8"))

1 个答案:

答案 0 :(得分:1)

您不想将ExecuteNonQuery用于SELECT,而是希望使用DataReader。请参阅以下说明:
https://msdn.microsoft.com/en-us/library/haa3afyz(v=vs.110).aspx

ExecuteNonQuery只返回受命令影响的行数。它适用于 not 返回值的SQL命令(例如INSERT,UPDATE和DELETE)。