Using Visual studio 2017, I tried to write and verify programming with a simple WebFormApplication to verify connectivity with SQL Server, but the test connection and build went well, but when I actually moved it, I got an "unhandled exception."What is the cause?
using System;
using System.Collections.General;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace TestConnection 2
{
public partial class Form 1:Form
{
public Form 1()
{
InitializeComponent();
}
public string contring="Server=localhost\\SQLEXPRESS; Database=master; Trusted_Connection=True";
private void button1_Click(object sender, EventArgse)
{
SqlConnection con=new SqlConnection(conString);
con.Open();
if(con.State==System.Data.ConnectionState.Open)
{
string q = "insert into User(id, name) values('+textID.Text.ToString()+"', '+textName.Text.ToString()+");
SqlCommand cmd = new SqlCommand(q,con);
cmd.ExecuteNonQuery();
MessageBox.Show("Connection made Successful.");
}
}
}
}
There was no problem using the same code.Is it a SQLEXPRESS issue?The User table is not known if it is in the master database.
600 GDB gets version error when attempting to debug with the Presense SDK (IDE)
610 Uncaught (inpromise) Error on Electron: An object could not be cloned
891 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
568 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.