473,651 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transpose data

I wrote an aplication that write something into tableA in sql2000.
I want to write the same, but transposed into tableB.
Someone can help me?
Any example?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
7 3593
Well just change your INSERT statement to reflect the new table name. Is
that what your looking for ?

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"Leszek Gruszka" <le************ @kana.com.pl> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I wrote an aplication that write something into tableA in sql2000.
I want to write the same, but transposed into tableB.
Someone can help me?
Any example?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #2
Yes, but i want to make it like datafill.transp ose (i know, that it
don't exists) or something like that.
But in my full aplication there will be about 50-100 columns.
I thought, that there is a way to transpose data in dataset and fill it
into other table (TableB). I created TableB with correct columns and i'm
trying to fill it. It's not qa problem, that Table or dataset will have
more columns then other one. How only fill rows?

My code:
Public Sub SQL_Wpis()
Dim sSQL As String
sSQL = "SELECT * FROM KanaSecRep"
Dim objConn As New SqlConnection(s Connection)
Dim objDataAdapter As New SqlDataAdapter( sSQL, objConn)
Dim objDS As New DataSet("KA_STA N")
Dim objInsertComman d As New SqlCommand
Dim sInsertSQL As String
Dim objParam As SqlParameter

If objConn.State = ConnectionState .Open Then
Try
objDataAdapter. MissingSchemaAc tion() = _
MissingSchemaAc tion.AddWithKey
objDataAdapter. Fill(objDS, "KanaSecRep ")
objConn.Close()
Dim objTable As DataTable
objTable = objDS.Tables("K anaSecRep")
Dim drRows As DataRowCollecti on
Dim objCurrentRow As DataRow
drRows = objTable.Rows
objConn.Open()
objDataAdapter. Update(objDS, "KanaSecRep ")

Dim sNowywpisSQLpiv = "INSERT INTO KanaSecRep" & "(Nazwastac ji, DC, MS,
Data, AuditBaseObject s, ShutdownWithout Logon" & " VALUES ('" &
strKomputer & "','" & IsDC(strKompute r) & "','" & IsMS(strKompute r) &
"','" & DateTime.Now & "','" & AuditBaseObject s(strKomputer) & "','" &
ShutdownWithout Logon(strKomput er) & "'
Dim objNewCmd As New SqlCommand(sNow ywpisSQLpiv, objConn)
objNewCmd.Execu teNonQuery()

Catch myException As System.Exceptio n
Console.WriteLi ne(myException. Message)
End Try
Console.Write(" Koniec")
End If
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3
Cor's previous post on this subject ( Untested by me ), does this help

-----------------------------------------------------------------

Cor Ligthert
Hi Chris,

It is very simple call the rows col and the col rows

Something like this, (goes for every table)

I hope this helps?

Cor
\\\
Dim dtnew As New DataTable
For i As Integer = 0 To dt.Rows.Count - 1
dtnew.Columns.A dd(i.ToString)
Next
For i As Integer = 0 To dt.Columns.Coun t - 1
Dim dr As DataRow = dtnew.NewRow
dtnew.Rows.Add( dr)
Next
For i As Integer = 0 To dt.Rows.Count - 1
For j As Integer = 0 To dt.Columns.Coun t - 1
dtnew.Rows(i).i tem(j) = _
dt.Rows(j).Item (i).tostring
Next
Next
///
--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmv ujpotXjui/OFU".ToCharArra y()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar( Convert.ToInt16 (ch(i)) - 1)
Next
Process.Start(" mailto:" & New String(ch))
--
"Leszek Gruszka" <le************ @kana.com.pl> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Yes, but i want to make it like datafill.transp ose (i know, that it
don't exists) or something like that.
But in my full aplication there will be about 50-100 columns.
I thought, that there is a way to transpose data in dataset and fill it
into other table (TableB). I created TableB with correct columns and i'm
trying to fill it. It's not qa problem, that Table or dataset will have
more columns then other one. How only fill rows?

My code:
Public Sub SQL_Wpis()
Dim sSQL As String
sSQL = "SELECT * FROM KanaSecRep"
Dim objConn As New SqlConnection(s Connection)
Dim objDataAdapter As New SqlDataAdapter( sSQL, objConn)
Dim objDS As New DataSet("KA_STA N")
Dim objInsertComman d As New SqlCommand
Dim sInsertSQL As String
Dim objParam As SqlParameter

If objConn.State = ConnectionState .Open Then
Try
objDataAdapter. MissingSchemaAc tion() = _
MissingSchemaAc tion.AddWithKey
objDataAdapter. Fill(objDS, "KanaSecRep ")
objConn.Close()
Dim objTable As DataTable
objTable = objDS.Tables("K anaSecRep")
Dim drRows As DataRowCollecti on
Dim objCurrentRow As DataRow
drRows = objTable.Rows
objConn.Open()
objDataAdapter. Update(objDS, "KanaSecRep ")

Dim sNowywpisSQLpiv = "INSERT INTO KanaSecRep" & "(Nazwastac ji, DC, MS,
Data, AuditBaseObject s, ShutdownWithout Logon" & " VALUES ('" &
strKomputer & "','" & IsDC(strKompute r) & "','" & IsMS(strKompute r) &
"','" & DateTime.Now & "','" & AuditBaseObject s(strKomputer) & "','" &
ShutdownWithout Logon(strKomput er) & "'
Dim objNewCmd As New SqlCommand(sNow ywpisSQLpiv, objConn)
objNewCmd.Execu teNonQuery()

Catch myException As System.Exceptio n
Console.WriteLi ne(myException. Message)
End Try
Console.Write(" Koniec")
End If
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #4
Why not just use two data adapters... updating from the same dataset, just
don't accept changes after update on the first one.
"Leszek Gruszka" <le************ @kana.com.pl> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Yes, but i want to make it like datafill.transp ose (i know, that it
don't exists) or something like that.
But in my full aplication there will be about 50-100 columns.
I thought, that there is a way to transpose data in dataset and fill it
into other table (TableB). I created TableB with correct columns and i'm
trying to fill it. It's not qa problem, that Table or dataset will have
more columns then other one. How only fill rows?

My code:
Public Sub SQL_Wpis()
Dim sSQL As String
sSQL = "SELECT * FROM KanaSecRep"
Dim objConn As New SqlConnection(s Connection)
Dim objDataAdapter As New SqlDataAdapter( sSQL, objConn)
Dim objDS As New DataSet("KA_STA N")
Dim objInsertComman d As New SqlCommand
Dim sInsertSQL As String
Dim objParam As SqlParameter

If objConn.State = ConnectionState .Open Then
Try
objDataAdapter. MissingSchemaAc tion() = _
MissingSchemaAc tion.AddWithKey
objDataAdapter. Fill(objDS, "KanaSecRep ")
objConn.Close()
Dim objTable As DataTable
objTable = objDS.Tables("K anaSecRep")
Dim drRows As DataRowCollecti on
Dim objCurrentRow As DataRow
drRows = objTable.Rows
objConn.Open()
objDataAdapter. Update(objDS, "KanaSecRep ")

Dim sNowywpisSQLpiv = "INSERT INTO KanaSecRep" & "(Nazwastac ji, DC, MS,
Data, AuditBaseObject s, ShutdownWithout Logon" & " VALUES ('" &
strKomputer & "','" & IsDC(strKompute r) & "','" & IsMS(strKompute r) &
"','" & DateTime.Now & "','" & AuditBaseObject s(strKomputer) & "','" &
ShutdownWithout Logon(strKomput er) & "'
Dim objNewCmd As New SqlCommand(sNow ywpisSQLpiv, objConn)
objNewCmd.Execu teNonQuery()

Catch myException As System.Exceptio n
Console.WriteLi ne(myException. Message)
End Try
Console.Write(" Koniec")
End If
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #5

Could you help me how put it into my code?
I used samples and wrote my code, but i don't know where put your
example.. :(

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #6
How do this?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #7
How are you updating your data now?

or doing your inserts that is... using a self written command? or something
like a SQL data adapter to do the work for you?

"Leszek Gruszka" <le************ @kana.com.pl> wrote in message
news:uU******** ********@TK2MSF TNGP10.phx.gbl. ..
How do this?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6422
by: jenny.rhodes | last post by:
Hello, Please can anyone guide me on how to transpose an access table where I have many records per id eg UserID Question Answer 1 1 a 1 2 d 1 3 c 1 4 d
1
2328
by: Jenny | last post by:
Hello, Please can anyone guide me on how to transpose an access table where I have many records per id eg UserID Question Answer 1 1 a 1 2 d
7
12051
by: sangeetha | last post by:
Hi, i need to transpose a nx1 matrix to 1xn matrix inorder to multiply with nxn matrix in c language ... can anyone help in this coding ..the nx1 matrix is pi the data type is double *pi..this is used through out the program ..now i need this transpose for further calculations.... Kindly help as soon as possible.....if this is not possible kindly suggest me something...
8
1916
by: Leszek Gruszka | last post by:
I wrote code, that fill TableA with records by executenonquery. But i want to have second TableB, that will be transposed TableA. My code: Public Sub SQL_Wpis() Dim sSQL As String sSQL = "SELECT * FROM KanaSecRep" Dim objConn As New SqlConnection(sConnection) Dim objDataAdapter As New SqlDataAdapter(sSQL, objConn) Dim objDS As New DataSet("KA_STAN")
3
3118
by: Gerard Brunick | last post by:
My way is ugly. These has to be a better way. Thanks, Gerard
6
4957
by: JayDawg | last post by:
Excel has this cool little function where you can copy data, and then paste it transposed so that which runs across the rows now runs down a colum and visa versa. Is there a way in access to create a report that would transpose the data from what is logical. I have a query that has a field for the date (by month) and then additional fields (15 of them) by which I enter in data. So in the Table/Query it is formated such that when the...
0
7270
by: shantanu | last post by:
I am trying to convert a macro code to c# that will copy the values of a column and paste to anather through paste special. Everything is working fine but the transpose meathod to paste the column value as row value is not working. Can someone kindly look into the code, if i am missing something. C# Code ------------ private void ManipulateXLS() {
4
4035
by: pc_whocares | last post by:
My forehead is flat from pounding. I am building a DLL in VS2005 C++ for use in another software development platform. I am required to pass my array data in/out of the function via a pointer, in this case, to double. The simplest way for me to transpose the array is via addressing its individual elements in the conventional form such as
5
12581
by: jenniferhelen | last post by:
I have been searching threads for a while and found the instructions listed below many times, however when I get to step 6 and select to save, I always receive the following error, "The information cannot be pasted because the copy area and the paste area are not the same size and shape". Does this function only work if the number or rows and number of columns are the same number? Does anyone have any suggestions for me? I greatly appreaciate...
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8278
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8584
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.