2
Answers

C# Databases

Photo of miro_beranic

miro_beranic

20y
2.3k
1
I have connected to the Database. But how do I read the data or add data to the already created data?

Answers (2)

0
Photo of jacobs
NA 7 0 20y
Dont no if you looking for this but this is a basic add func. public bool addUser(string argUsername, string argPassword, string argStatus, int argCusID, ref string msg) { string sql = "INSERT INTO LOGIN " + " (UserName,Password,Status,Cust_ID) " + " VALUES " + " ('" + argUsername + "','" + argPassword + "','" + argStatus + "','"+ argCusID + "')"; bool insertState = false; conn = new SqlConnection(connString); cmd = new SqlCommand(sql,conn); da = new SqlDataAdapter(cmd); try { conn.Open(); cmd.ExecuteNonQuery(); //sets insertstate to true if insert was successfull insertState = true; } catch (Exception ex) { msg = ex.Message; } conn.Close(); return insertState; }
0
Photo of shimtanny
NA 436 0 20y
Hi Use the classes OleDbConnection, OleDbCommand, OleDbDataAdapter, respectivly sql versions of the connection, command and data adapter. Simon