Created
March 12, 2021 13:50
-
-
Save reuniware/a515f2279caa821041ddfeff01840e75 to your computer and use it in GitHub Desktop.
Windev 26, C#, SQL Server Insert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Data.SqlClient; | |
using System.Drawing; | |
using System.Text; | |
using System.Windows.Forms; | |
public static bool InsertCSharp(String sql) | |
{ | |
try { | |
string connectionString; | |
SqlConnection cnn; | |
connectionString = @"Data Source=MYSQLSERVER;Initial Catalog=;User ID=username;Password=password123"; | |
cnn = new SqlConnection(connectionString); | |
cnn.Open(); | |
//MessageBox.Show("Connection Open !"); | |
SqlDataAdapter adapter = new SqlDataAdapter(); | |
SqlCommand command = new SqlCommand(sql, cnn); | |
adapter.InsertCommand = command; | |
adapter.InsertCommand.ExecuteNonQuery(); | |
//command.Dispose(); | |
//cnn.Close(); | |
return true; | |
} | |
catch(Exception ex) | |
{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment