C#数据库内容 打的代码和书上一样 结果不同

来源:百度知道 编辑:UC知道 时间:2024/07/05 00:03:12
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 第十五章_Command对象
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection A;

private void Form1_Load(object sender, EventArgs e)
{
A = new SqlConnection("server=.;database=db_foavin;uid=sa;pwd=");
A.Open();
}

private void button1_Click(object sender, EventArgs e)
{
try
{
if (A.State == ConnectionState.Open || textBox1.Text != "")
{
SqlCommand B = new SqlCommand();

如果说错了,,,唯一的错误是你的
B.CommandText = "select count(*) from" + textBox1.Text.Trim();
cmd.CommandText = "select count(*) from " + textBox1.Text.Trim();

看出来了吗,,from 后多一个空格和少一个空格

C#数据库内容 打的代码和书上一样 结果不同
悬赏分:5 - 离问题结束还有 14 天 23 小时
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 第十五章_Command对象
{
public partial class Form1 : Form
{

这个 这个。。。

namespace 第十五章_Command对象

namespace Test03

不同..