ADO.NET :: Insert ID Which ID Is Auto - Increase In Table Of Database?
Mar 24, 2011
How to insert a auto increase in table of database? table TechCode consist TechCodeID and TechCodeDesc These following are my code
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim strTechCode As String
strTechCode = tbAdd.Text
Dim sqlCon As New SqlConnection
sqlCon = db.getConnection()
If sqlCon.State = ConnectionState.Closed Then
sqlCon.Open()
End If
Using sqlCmd As SqlCommand = sqlCon.CreateCommand()
sqlCmd.CommandText = "InsertTechCode"
sqlCmd.CommandType = CommandType.StoredProcedure
'TechCodeID is the auto increase ID in database
sqlCmd.Parameters.AddWithValue("@TechCodeID", Decimal.Parse("TechCodeID"))
sqlCmd.Parameters.AddWithValue("@TechCodeDesc", strTechCode)
sqlCmd.ExecuteNonQuery()
If sqlCon.State = ConnectionState.Open Then
sqlCon.Close()
End If
End Using
End Sub
rowid (int, not null) pid(nvarchar(1020), null) gid(nvarchar(1020),null) tid((nvarchar(1020),null)
I get value of pid, gid and tid from dropdown box. I would like to insert pid, gid, tid into TableOne. How to auto increase rowid when insert into this table?
I am using MasterPage and using using a CSS in master page. My problem is in its content page, I have a messgage box comes up in some condition resulting FONT SIZE INCREASE. I do not have any font specification in my content page. I do not know how my content page font size change when I click on "OK" to my message box.
I have project in asp.net with sql server backend.i want to auto generate a number for particular column.with the auto generated number i want to insert some other data in the same row same table. on button click event.details
railway PNR no.:- want to autogenerat passenger details:- want to inserted simultaneously
I have a simple online web system where it possible for the visitors to "play around" with the system. They can like create categories and products and so forth. Everything they create are stored into a database.
What I want is to be able to reset this database with my default values (table data) every n hours.
So for example if we have a bunch of users that have played with the system and created new things. Then I want to be able to make some kode that deletes all data in the tables in this database and fill it with default data. The default data can come from a backup file, or another database with same tables structure or whatever.
I want this task to be done every day at 12 pm or every n hour.
Is this possible (by forexample scheduled webservice tasks or just something as long as it is simple).
how can insert a data on a table in a database.I wanna do it without using any Data Control,because I'd like to make my site layout personalized.What is the easiest way for doing it in C#?
I am doing a data warehouse project.I have two tables tblA (id, type) and tblB(city, no_crimes, type).I want to create (insert) a number of rows based on the value of no_crimes.For Example, in tblB(Leeds, 2000, murder). SO, I need to insert 2000 rows into tblA by a single INSERT statement (not 2000 statements).
OleDbException (0x80040e57): The statement has been terminated. String or binary data would be truncated.] System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +745 System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +113
I have used "Auto complete Extender" ajax control. It is working fine.But , fetching the data from database is very slow. Even though i have used stored procedure, Datareader, and caching on that controls. I m expecting like "Google type" .
I am using ASP.Net 4.0/Visual Studio 2010. However, I think it would be the same if it was ASP.Net/VB.Net 3.5. I am inserting three form filed values into a database table. I have placed a LoginName Control on the page and the login name is properly displaying. I am using forms Authentication and it is set up properly in the web config file. I simply want to insert the logged in username value into the database table so I can track who created the records. I am happy to be able to insert the UnserName or the UserID value. I assume both of the values are derived out of the aspnet_Users table. Being able to insert either one would be fine but I believe UserID would be better because it will always be unique.
I have an excel sheet that contains around 30,000 rows and 18 colmns. These no of rows and columns may increase in future. I need to read all these records from excel sheet and insert into a table in sql database. For reading the excel book I am using Oledbconnections. The possible solutions I have known as per my knowledge, to insert the data are
1. To insert one record at a time which makes 30,000 database hits. How will this affect the performance? 2. To use liked servers - bu this is not working for me.I do not have database permissions to use linked servers. So, the only option i have is the first one.
<table> <tr> <td>//1 //some control server side </td> </tr> <tr> <td>//2 //some control server side </td> </tr> <tr> <td>//3 //some control server side </td> </tr> </table>
i like when increase hegiht content of td.1 then increase hegiht of td.2 and td.3 automaticly.
I work with Visual studio 2005 and Sql server data base. I extract 1 million rows from a database and I put the rows in a Sql table. With a simple direct extraction, in a few minutes I complete the operation:
Dim cmd As New SqlCommand(query, cnSql) cmd.ExecuteNonQuery() cmd.Dispose().
But, if I must select and modify some fields between extraction and introduction, it takes a lot of time! I work in this way. I extract rows from Dbase, Table1, and I put all into a Collection using dataReader:
Dim cmd As New SqlCommand(query, cnSql) Dim coll As New Collection coll.Clear() Dim dr As SqlDataReader = cmd.ExecuteReader() I replace some fields with the string "YES". Dim toRepl As String = "" If dr.HasRows Then Do While dr.Read toRepl = dr(5).ToString If Len(toRepl) <= 3 Then ToRepl = "YES" collPrel.Add(dr(0).ToString) collPrel.Add(dr(1).ToString) .................. .............. collPrel.Add(toRepl) collCount = collCount + 1 Loop End If dr.Close() cmd.Dispose() Now, I insert all into a SQL Table2: Dim a As String = "", b As String = "", c As String = "" etc. For i = 1 To collPrel.Count Step 6 a = collPrel.Item(i).ToString b = collPrel.Item(i + 1).ToString .............. ............... f = collPrel.Item(i + 5).ToString queryIns = "INSERT INTO Tab (name, adress, etc) VALUES ('" & a & "', '" & b & "', '" & c & "', etc. ) Dim cmdIns As New SqlCommand(queryIns, cnSql) cmdIns.CommandTimeout = 600 cmdIns.ExecuteNonQuery() cmdIns.Dispose() Next
This way to work goes right but it is necessary a lot of time for completing the operation.