|
I think the suitable solution might be came from using batch file with script file. You can write script file to perform the action what you do, it is not reach any action then post the scrite file to inform the user that it is not working and vice versa. I'm rarely to use this kind of action too but try to check the script at Microsoft Scripting Center.[^]
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hello,
I've been trying to move items up and down in a DataGrid in the .Net Compact Framework, using Visual Basic .Net 2003. I have tried using the InsertAt command, but I have not been able to get it to work.
Here is my current code to move an item up:
Dim currentpos As Integer
currentpos = DataGrid1.CurrentRowIndex
If currentpos >= 0 Then
Dim row As DataRow
row = DataTable.Rows(DataGrid1.CurrentRowIndex)
Dim NewRow As DataRow
NewRow = DataTable.NewRow
NewRow(0) = row.ItemArray.GetValue(0)
DataTable.Rows.RemoveAt(DataGrid1.CurrentRowIndex)
DataTable.Rows.InsertAt(NewRow, currentpos - 1)
End If
My code seems to sometimes work, other times it moves two items up, and sometimes it moves items around randomly.
Could anyone please help?
Thanks
|
|
|
|
|
What is your DataGrid bound to? Move the data around in the datasource, not the grid itself.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
My DataGrid is bound to a DataTable.
In my form's declorations, I have:
Dim DataTable As DataTable
Dim MyDataSet As New DataSet In the custom function that sets the DataSource (without the extra code that loads in the XML data into the MyDataSet's DataTable, DT1):
DataTable = MyDataSet.Tables("DT1")
DataGrid1.DataSource = DataTable Thanks
|
|
|
|
|
In that case, you can move records around in the DataTable and then Refresh the DataGrid after the modification is completed. Once all your changes are made, you can have the DataSet object that the DataTable is in write the XML file back out.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
I haven't been able to find any methods that would allow me to move items up and down. Could it be possible restrictions on the DataTable in the .Net Compact Framework?
Thanks
|
|
|
|
|
Try this source, after you plug in a value for yourDLLpath
Dim yourDLLpath As String = ""
Dim asm As [Assembly] = asm.LoadFrom(yourDLLpath)
Try
Dim oTyp As Type
For Each oTyp In asm.GetTypes
If oTyp.BaseType.FullName = "System.Web.UI.Page" Then
Dim pi As PropertyInfo = oTyp.GetProperty("Controls.Count", GetType(Integer))
Dim valueOfControls As ControlCollection
valueOfControls = pi.GetValue(oTyp, Nothing)
End If
Next
I cannot get rid of the "Object does not match target type error." I'm getting with the line : valueOfControls = pi.GetValue(oTyp, Nothing) How do I get the value of the controls? I'm trying to iterate through the controls on web pages to get values of certain control types. Thanks.
|
|
|
|
|
Your problem is twofold.
1) The code to get the property is wrong. the line to get the Controls property should read :
Dim pi As PropertyInfo = oTyp.GetProperty("Controls")
2) The first parameter of the GetValue method takes the instance of the object from which you require the value. You have passed it the Type object instead. Clearly web page controls, or any controls, have no values until you initialise them. You could create instances of the webpage classes using Activator.CreateInstance and test those, or do things a different way.
|
|
|
|
|
Hello All:
Does anyone not know anything about importing databases. I have posted two threads and no one has responded. Am I not in the right forum?
Thanks
|
|
|
|
|
1) Your questions should be posted in the SQL/ADO/ADO.NET Forum.
2) You haven't posted any real questions other than "Can someone help me?". Help you with what? What code are you having a problem with?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Try to post the question, what you want to know about importing database? Tell the problem that you face.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Can please anyone help me with this one.. I am trying to import selected tables and fields from an ODBC Data Connection Source to an access databse. Your help would be very much appreciated. Thanks.
|
|
|
|
|
Help with what? You haven't asked any questions we can answer...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am trying to import tables and selected fields from an ODBC Source to Access. Can anyone help me with the code that automatically imports selected tables and fields from the external database. The connection to the database is thru ODBC. Does this Help?
|
|
|
|
|
There is nothing that will "automatically" do this. You must write the code to reads one database and posts the data to another. What code have you written so far?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave:
what I meant by automate is doing it via VB Code. I dont have any code yet. I know there are 2 phases to this.
#1 to be able to connect to the external databse. (need code for this)
#2 to be able to read and import tables into access. (need code for this)
Scenario:
In External Database Import to Access
Table1 ----> Export table1 (selected fields)
Table2
Table3 ----> Export to Access (selected fileds)
Table4
|
|
|
|
|
Is there anything you don't need code for? You just described needing code for the entire application. Not gonna happen here. You have to try it yourself first.
If your importing into Access, why not just use the "Get External Data" wizard of the "Table Link" wizard. It will let you do everything you've described so far.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave:
I am trying to write a application. The part I dont understand is how to automatically pull in data from external source. This is not the full application, but it is the main component of extracting data into the system. I cannot use the wizard process because I need the data extraction part to be processed when the application is started. I know how to connect to the source, but dont know how to instruct the code to only import few tables and selected fields out of the table. All I am looking for is some generic code help and I can go from there. If you don't want to share any thoughts, could you at least point me to a resource site or something where I can get basic concept on getting this code going. Many Thanks.
|
|
|
|
|
This part requires a little SQL to select the tables and fields you want returned in a recordset. The Web, and Access' documentation, is filled with examples of how to do this. (I assume your writing this in VBA for Access.) I don't have any code examples, in VBA, to show you because I haven't used Access for anything in years. Just look in the Access documentation for the terms Connection, Command and Recordset and you'll find all the objects you need to read and write a database and examples to go with it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave:
I really appreciate your help this far. This is what I have got so far.
Private Sub ImportToAccess()
Dim Con1 As New ADODB.Connection
Dim Con2 As New ADODB.Connection
Dim mySQL1 As String
Dim mySQL2 As String
Dim myDSN As String
Dim mySET As String
myDSN = "DSN=Springbrook1;UID=suresh;PWD=******;"
mySET = "set schema 'pub'"
mySQL2 = "select * from customer"
Con1.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Temp\VB Sample Codes\mcwd\Connect Program\test1.mdb;" & _
"Jet OLEDB:Engine Type=5;"
Con2.Open myDSN
Con2.Execute (mySET)
mySQL1 = "SELECT * INTO [tblCutomer] FROM [mySQL2]"
Con1.Execute mySQL1
Set Con1 = Nothing
Set Con2 = Nothing
Con2.Close
End Sub
I am getting the following error message:
The Microsoft Jet databse engine cannot find the input table or query 'mySQL2'. Make sure it exists and that its name is spelled correctly.
Is my code correct? Am I missing something for the mySQL2 line. If this works, I am sure I can define selected fields to be imported. Thanks for your help.
|
|
|
|
|
Suresh Prasad wrote:
The Microsoft Jet databse engine cannot find the input table or query 'mySQL2'. Make sure it exists and that its name is spelled correctly.
I think something problem with your string. In the code mySQL2 is the SQL statement that declare above and your system try to look in the database as the table. It look like this because write this code:
Suresh Prasad wrote:
mySQL1 = "SELECT * INTO [tblCutomer] FROM [mySQL2]"
look at the bold text that you write, your system will look into your database for table mySQL2 . I'm not sure what you want to do with the above SELECT statement but what i guest is you try to insert the data that you want to import in your system from the result of the data that you select. As far as I know, if the structure of add the new record in datase is INSERT INTO not SELECT INTO ... (not sure too). But I just suggest you that try to use loop (but it could take some time to do that) to read the record one by one from the source then insert it in your database. This is the concept only try to do it by yourself and let me know if you face any problem.
Suresh Prasad wrote:
mySQL1 = "SELECT * INTO [tblCutomer] FROM [mySQL2]"
Con1.Execute mySQL1
Set Con1 = Nothing
Set Con2 = Nothing
Con2.Close
End Sub
On the other hand, your code above did not close the Con1 and Con2 connection object. I think a good practice you should close it first then set it to nothing .
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Can anyone tell me whats wrong with my code. I am getting a syntax error on the INSERT staement. Also, will this work to import the data into access.
Private Sub ImportToAccess()
Dim Con1 As New ADODB.Connection
Dim Con2 As New ADODB.Connection
Dim mySQL1 As String
Dim mySQL2 As String
Dim myDSN As String
Dim mySET As String
'Connection parameters for Source Database
myDSN = "DSN=Springbrook1;UID=suresh;PWD=****;"
mySET = "set schema 'pub'"
mySQL2 = "select * from customer"
'Open Source Database
Con2.Open myDSN
Con2.Execute (mySET)
'Open Destination Database
Con1.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Temp\VB Sample Codes\mcwd\Connect Program\test1.mdb;" & _
"Jet OLEDB:Engine Type=5;"
'Read from Source Database
mySQL1 = "SELECT Cust_No, First_Name, Last_Name FROM [odbc;DSN=Springbrook1;UID=suresh;PWD=nissan;].[Customer]"
'Import Data to Destination Database
mySQL2 = "INSERT INTO [C:\Temp\VB Sample Codes\mcwd\Connect Program\test1.mdb].[tblCustomer] "
Con1.Execute mySQL1
Con1.Execute mySQL2
Con1.Close
Con2.Close
Set Con1 = Nothing
Set Con2 = Nothing
End Sub
|
|
|
|
|
First, you can't use a SELECT statement to transfer data between two physically seperate databases.
Second, your only opening one database. You haven't setup anything to open the second one where your going to transfer data to.
Third, you have to retrieve the records from your first database, and one at a time, do any processing you need to on the data, and use an INSERT sql statement/command object to insert the data into the new database.
The pseudo-code looks something like this:
' Open source database connection
' Open destination database connection
' Retrieve all the records we need from the source database
' For each record in source recordset
' Assign values from record fields to parameters in SQL INSERT command,
doing any translation or processing required.
' Execute INSERT command
' Next
' Close destination database connection
' Close source database connection
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
This is an English-speaking board...
And I'm not clicking on a link going to Russia...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|