1
이것은 텍스트 필드에서 데이터베이스에 삽입하기위한 코드입니다.textBox의 값이 데이터베이스에 삽입되지 않음
SqlConnection Connection = new SqlConnection("Data Source=ESHA\\SQLEXPRESS;Initial Catalog=Gen_Lic;User ID=sa;[email protected]");
SqlCommand Command = Connection.CreateCommand();
try
{
// Open Connection
Connection.Open();
////Console.WriteLine("Connection Opened");
// Create INSERT statement with named parameters
Command.CommandText = "INSERT INTO Gen_Lic(Lic_No, UserID, Org, UserName, SolType, Version, Lic_Type, Meap_Supp, Lic_From, Lic_To, Supp_From, Supp_To, Max_User, Max_Mach, Mach_IP, Mach_MAC) VALUES (@Lic_No, @UserID, @Org, @UserName, @SolType, @Version, @Lic_Type, @Meap_Supp, @Lic_From, @Lic_To, @Supp_From, @Supp_To, @Max_User, @Max_Mach, @Mach_IP, @Mach_MAC)";
// Add Parameters to Command Parameters collection
Command.Parameters.AddWithValue("@Lic_No", txtLNo.Text);
Command.Parameters.AddWithValue("@UserID", txtUID.Text);
Command.Parameters.AddWithValue("@Org", txtOrg.Text);
Command.Parameters.AddWithValue("@UserName", txtUName.Text);
Command.Parameters.AddWithValue("@SolType", txtSType.Text);
Command.Parameters.AddWithValue("@Version", txtVer.Text);
Command.Parameters.AddWithValue("@Lic_Type", drpLType.SelectedItem.Text);
Command.Parameters.AddWithValue("@Meap_Supp", rdoMeapSupport.SelectedValue.ToString());
Command.Parameters.AddWithValue("@Lic_From", lblLFrom.Text);
Command.Parameters.AddWithValue("@Lic_To", lblLTo.Text);
Command.Parameters.AddWithValue("@Supp_From", lblSuppFrom.Text);
Command.Parameters.AddWithValue("@Supp_To", lblSuppTo.Text);
Command.Parameters.AddWithValue("@Max_User", txtMaxUsr.Text);
Command.Parameters.AddWithValue("@Max_Mach", txtMaxMach.Text);
Command.Parameters.AddWithValue("@Mach_IP", txtMachIP.Text);
Command.Parameters.AddWithValue("@Mach_MAC", txtMachMac.Text);
Connection.Close();
}
이제 문제는 코드가 정상적으로 작동하지만 값이 데이터베이스에 삽입되지 않는 것입니다. 또한 연결 형성 시작시 중단 점을 적용하면 새로운 빈 IE 창이 열립니다.
누군가 나를 안내 할 수 있습니까?
는 감사의 연결을 닫기 전에 다시 쿼리 데이터베이스
을 실행하십시오 ! :) 완벽하게 작동합니다! – Esha