(我的数据库没有密码 ) private void button1_Click(object sender, System.EventArgs e) { string tb = textBox1.Text; InsertTable(tb);
} public void InsertTable(string tbb) { SqlConnection conn = new SqlConnection(); conn.ConnectionString ="data source=.;initial catalog=model;persist security info=False;user id=sa;password=;"; SqlCommand cmm = new SqlCommand(); try { conn.Open(); cmm.Connection = conn; cmm.Parameters.Add("@id",tbb); cmm.CommandText = "insert into h1 (id) values (@id)"; } catch(Exception ex) { string e = ex.Message; } finally { conn.Close(); cmm.Dispose(); }
} 我这样写为什么在数据库表里没有插入数据呢 帮我分析下,是我连接数据库的问题吗