Click here to Skip to main content
15,888,157 members
Home / Discussions / Database
   

Database

 
GeneralRe: Login Pin
Christian Graus1-Jul-05 20:20
protectorChristian Graus1-Jul-05 20:20 
GeneralRe: Login Pin
Desi Bravo3-Jul-05 4:37
Desi Bravo3-Jul-05 4:37 
GeneralRe: Login Pin
Christian Graus3-Jul-05 11:31
protectorChristian Graus3-Jul-05 11:31 
GeneralRe: Login Pin
Anonymous3-Jul-05 16:25
Anonymous3-Jul-05 16:25 
GeneralRe: Login Pin
Christian Graus3-Jul-05 16:36
protectorChristian Graus3-Jul-05 16:36 
Generalreplace function Pin
Anonymous30-Jun-05 15:45
Anonymous30-Jun-05 15:45 
GeneralRe: replace function Pin
Michael Potter1-Jul-05 10:45
Michael Potter1-Jul-05 10:45 
GeneralInsert Record into Database. What is wrong? Urgent. Thank You. Pin
shapper30-Jun-05 10:49
shapper30-Jun-05 10:49 
Hello,

I need to add a new record in an Access database. The database has 4 fields:
[id] (autonumber)
[title] (string)
[text] (memo)
[publication_date] (DateTime)

I created my code but it's not working. I can't find the problem.

Can someone help me?

My code is as follows:

Dim connectionString As String =
System.Configuration.ConfigurationSettings.AppSettings("connectionString")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "INSERT INTO [t_news] ([title], [text], [publication_date]) VALUES (@title, @text, @publication_date)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection

Dim dbParam_title As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter dbParam_title.ParameterName = "@title"
dbParam_title.Value = "title example"
dbParam_title.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_title)

Dim dbParam_text As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter dbParam_text.ParameterName = "@text"
dbParam_text.Value = "text example"
dbParam_text.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_text)

Dim dbParam_publication_date As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter dbParam_publication_date.ParameterName = "@publication_date"
dbParam_publication_date.Value = DateTime.Now
dbParam_publication_date.DbType = System.Data.DbType.DateTime
dbCommand.Parameters.Add(dbParam_publication_date)

Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try

Thanks,
Miguel

GeneralSelect command won't work after Insert command in stored procedure Pin
jchsiung230-Jun-05 10:15
jchsiung230-Jun-05 10:15 
GeneralRe: Select command won't work after Insert command in stored procedure Pin
Scott Serl30-Jun-05 12:33
Scott Serl30-Jun-05 12:33 
GeneralRe: Select command won't work after Insert command in stored procedure Pin
jchsiung25-Jul-05 7:28
jchsiung25-Jul-05 7:28 
Generalproduct studio Pin
ziczaczoom200430-Jun-05 7:39
ziczaczoom200430-Jun-05 7:39 
GeneralMSDE slowing down Pin
Luis Alonso Ramos30-Jun-05 6:50
Luis Alonso Ramos30-Jun-05 6:50 
GeneralRe: MSDE slowing down Pin
Colin Angus Mackay30-Jun-05 7:10
Colin Angus Mackay30-Jun-05 7:10 
GeneralRe: MSDE slowing down Pin
Luis Alonso Ramos30-Jun-05 7:29
Luis Alonso Ramos30-Jun-05 7:29 
GeneralReplication Pin
skrishnasarma29-Jun-05 23:28
skrishnasarma29-Jun-05 23:28 
GeneralRe: Replication Pin
StylezHouse30-Jun-05 2:53
StylezHouse30-Jun-05 2:53 
GeneralUnsigned numbers Pin
Jack Puppy29-Jun-05 11:44
Jack Puppy29-Jun-05 11:44 
GeneralRe: Unsigned numbers Pin
toxcct30-Jun-05 6:25
toxcct30-Jun-05 6:25 
GeneralArchitecture question Pin
klenne29-Jun-05 1:37
klenne29-Jun-05 1:37 
GeneralRe: Architecture question Pin
StylezHouse29-Jun-05 2:25
StylezHouse29-Jun-05 2:25 
GeneralRe: Architecture question Pin
Mattias Olgerfelt29-Jun-05 4:45
Mattias Olgerfelt29-Jun-05 4:45 
GeneralRe: Architecture question Pin
toxcct30-Jun-05 6:32
toxcct30-Jun-05 6:32 
GeneralT-SQL Pin
98022829-Jun-05 1:20
suss98022829-Jun-05 1:20 
GeneralRe: T-SQL Pin
StylezHouse29-Jun-05 2:30
StylezHouse29-Jun-05 2:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.