Tag: ado.net

best way to migrate a windows forms application from sql server to oracle

I looking for a best way to migrate a Windows Forms application from MS SQL Server to Oracle. The table schema is recreated in oracle allready and the data was copied into Oracle tables. The App uses ADO.NET Datasets to access the DB. So, should I just kind of replace all references to SqlDataAdapter with […]

compare databases (tables only) using C# and Ado.net

I am trying to develop a software that takes two databases as its input, compares there tables and show differences between tables. This is what I think and develop. 1) Select all the servers that are installed on machine. 2) Depending on the selected server it list all the databases installed. 3) Depending upon the […]

Column does not allow nulls

Please have a look at my code below and tell me where i am going wrong. case “particulars.aspx”: dt = JobCardManager.GetParticularsByJobId(id); hidJobId.Value = id.ToString(); if (dt != null && dt.Rows.Count > 0) { gvParticulars.DataSource = dt; gvParticulars.DataBind(); } else { **dt.Rows.Add(dt.NewRow());** gvParticulars.DataSource = dt; gvParticulars.DataBind(); int TotalColumns = gvParticulars.Rows[0].Cells.Count; gvParticulars.Rows[0].Cells.Clear(); gvParticulars.Rows[0].Cells.Add(new TableCell()); gvParticulars.Rows[0].Cells[0].ColumnSpan = TotalColumns; […]

Batch Update Table Across Non Linked SQL Servers

I am trying to update a table across “non-linked” SQL servers using: C# or VB.net and ADO.net SqlDataAdapter. I need to use DataTable and SqlDataAdapter. Very Important: I need to use BatchUpdate and avoid looping through the DataTable. The table designs in Server 1 differ from table design in Server 2. Source Table: Server 1. […]

How can I create two commands in one connection?

For example I want to INSERT data in database and also UPDATE another table. My code is like this SqlConnection con = new SqlConnection(“**”); con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandText = “INSERT Borrowbook VALUES (@StudentID, @ISBN, @Title, @Date)”; SqlParameter p1 = new SqlParameter(“@StudentID”, SqlDbType.NChar); p1.Value = textBox2.Text; cmd.Parameters.Add(p1); SqlParameter p2 = new SqlParameter(“@ISBN”, SqlDbType.NVarChar); p2.Value […]

TSQL try catch transaction error handling, transaction count mismatch

I have a sproc that I am calling from C# with a transaction by doing: using (var dbContext = PowerToolsDatabase.GetDataContext()) { dbContext.Connection.Open(); using (dbContext.Transaction = dbContext.Connection.BeginTransaction(System.Data.IsolationLevel.Serializable)) { foreach (var element in package.AddOrUpdateElements) { dbContext.usp_Element_Commit( /* args */); } dbContext.Transaction.Commit(); } } And in that sproc there is a try catch, and a RAISERROR inside the […]

Copy data from one database to another using VB.NET

I need to copy data from one database to another using a VB.NET program. The target database is SQL Server the source database is some proprietary ODBC compliant database. I need to loop through a list of table to copy. Read the data from the source database table for a given modified date. Delete the […]

How to display query results from SQL server in VB?

I am trying to display query results from SQL server in VB. I wrote following code, but not getting how to “Just display the results”; Public Function ConnectToSQL() As String Dim con As New SqlConnection Try con.ConnectionString = “Data Source=(local);Initial Catalog=TestDatabase;Persist Security Info=True;User ID=sa;Password=afm” Dim cmd As New SqlCommand(“SELECT username FROM users WHERE username=’user'”, con) […]

SQL Parameter for ALL

I was wondering if there was a parameter in SQL for all (not *!) For example, I’m writing a search table now, and if the user does not input something in the text box, it would mean to ignore that specific parameter and display ALL of them for that field. I understand you could make […]

Long time to load first sql connection in .NET

For some reason it takes 7 seconds to open a connection to a sql server database for the firt time, subsequent connections takes a second. any idea what could be the reason? I’m using C# and asp.net Its after compilation, i essence every time i restart the site, which means every time it needs to […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.