Author |
Topic |
deekshitulu
Starting Member
8 Posts |
Posted - 2012-09-15 : 03:55:10
|
Sir,SQL SERVER, 2005Visual basic 6 as front end.Database Name: GRANTH3ODBC data source Name : saiTable Name: CATSNumber of Field in the Table is :73I need to load date from the following Fields in the above table CATS to list view controlRequired Field: No of Field in 73DATA_ADDED 29ACCESSION_NO 57TITLE 7PUB_ID1_NAME 61CLASS_NAME 71I wrote following code: Sub LoadData()ListView1.ListItems.ClearDim list As ListItemDim x As Integerconnectdbrs.Open "SELECT ACCESSION_NO,TITLE,PUB_ID_NAME,CLASS_NO FROM CATS", conn, adOpenStatic, adLockOptimistic'rs.Open "SELECT TITLE,ACCESSION_NO,DATE_ADDED FROM CATS"Do Until rs.EOFSet list = ListView1.ListItems.Add(, , rs(0))For x = 1 To 3list.SubItems(x) = rs(x)Next xrs.MoveNextLoopSet rs = Nothing'db.Close: Set db = NothingEnd Sub But it is giving an error 94 ‘in valid use of nullAnd high lighting the following line of codelist.SubItems(x) = rs(x) is there any possibility to copy and paste the table and rename the table and delete the not required fields so that I execute the string "rs.open"Select * from CATS), conn,3,3"ch.s.deekshitulu |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-15 : 22:04:40
|
you can do SELECT <your required columns alone> INTO NewTable FROM CATSThen do rename of table to what you want usingEXEC sp_rename 'NewTable', 'your new name'------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
deekshitulu
Starting Member
8 Posts |
Posted - 2012-09-16 : 02:42:29
|
Sir,Where I have to put this line of code ie.,SELECT <your required columns alone> INTO NewTable FROM CATSin my above code (after which line of code?)Thanks in advancech.s.deekshitulu |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-16 : 12:17:42
|
quote: Originally posted by deekshitulu Sir,Where I have to put this line of code ie.,SELECT <your required columns alone> INTO NewTable FROM CATSin my above code (after which line of code?)Thanks in advancech.s.deekshitulu
the place where you've to create a new table with columns you need to use the above statement------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
deekshitulu
Starting Member
8 Posts |
Posted - 2012-09-16 : 18:31:56
|
Sir,can i write above statemnt like below:rs.MoveNextLooprs.Open"SELECT ACCESSION_NO,TITLE,PUB_ID_NAME,CLASS_NO INTO NewTable FROM CATS",conn,adOpenStatic, adLockOptimisticSet rs = Nothingby expending the table, I see a sub list like below:database diagramsTablesviewssynonymsprogramabilitysecuritycan i attach view of a table to listview control like a table attached to listview control Thanks in advancech.s.deekshitulu |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-16 : 22:42:30
|
quote: Originally posted by deekshitulu Sir,can i write above statemnt like below:rs.MoveNextLooprs.Open"SELECT ACCESSION_NO,TITLE,PUB_ID_NAME,CLASS_NO INTO NewTable FROM CATS",conn,adOpenStatic, adLockOptimisticSet rs = Nothingby expending the table, I see a sub list like below:database diagramsTablesviewssynonymsprogramabilitysecuritycan i attach view of a table to listview control like a table attached to listview control Thanks in advancech.s.deekshitulu
sorry you mean populate listview with table data?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
deekshitulu
Starting Member
8 Posts |
Posted - 2012-09-16 : 23:26:54
|
sir,actual fact is i am working in a library. about one lakh books data is entered in sql server 2005 database file. But I have developed a small project in vb6 as a front end with MS access back end. re entry of all the data is laborious job. to avoid this i wish to trasfer data from sql table to ms access table via listview control. for the purpose first i try to attach the sql table to listview control, it is successful, But I unable to send the data in listview control to a table with same and with same column in access database which is using back end in my project. For these purpose i put a save button in my Form and wrote code as above, But i am not succeed till now I request your kind cooperation in this matter.Thanks in advancech.s.deekshitulu |
|
|
deekshitulu
Starting Member
8 Posts |
Posted - 2012-09-18 : 01:48:50
|
Mr.Viskhm please respond to my topicThanksch.s.deekshitulu |
|
|
|