Jump to content
Xtreme .Net Talk

fkheng

Avatar/Signature
  • Posts

    156
  • Joined

  • Last visited

Everything posted by fkheng

  1. yeah, it is, but i did not know before...
  2. ok, thanx, i'm leaving for home now, will take a look at it later on, thanx...
  3. i see, thanx, will try these out, very helpful indeed...
  4. How do I remove spaces from a string if I only want a single word? What is the method for doing it?
  5. How do I control what happens when a form is closed? I know in VB6 it was through the unload event, but how do I code this in VB.NET? Which event do I refer to? Also, I have a splash screen, and after it is done, I hide it. After I close another form which it opened, my application does not terminate fully. I suspect this is due to the "Hide" operation I called. Is there anyway to come around this problem?
  6. Form show methods I have a form. I want to reveal anotyher form from it. Therefore, i hide the current form to reveal the new form using showDialog. In this showDialog form, can I open another form from this point?
  7. Hm........just would like to know if I have questions regarding coding Palm related applications, which forum discussion category should I visit?
  8. I know this is silly, but wat is the purpose of this forum category - Interoperation / Office Integration? What sort of systems, programs or coding would fall under this category?
  9. I am loooking into creating a project whereby a few computers, for example, who are registered with a system which rests on a server nearby can gain access to some services...for example, from a basic point of view, being able to chat with all connected users... i have not learnt the VB.NET way of coding a network application, but i am willing to pick it up... could anyone please let me know what are teh basics and elements i would need to know and implement in order to achieve the basic underworkings of this system i have in mind?
  10. then wat is the point of using an oledbcommand object if the data adapter already uses the sql statement?
  11. wow, the explanation about the parameters is quite confusing...in the first place, why would we have to redefine parameters and create objects for them if the data adapter has already mapped all the parameters from the data source to the data set?
  12. i see, thank you so much jfackler! however, i realise that my oledbcommand variable 'cmSQL' is not used anywhere in this code, apart from initialising it...does it play any part here? if not i should delete it... if i want to reflect the changes of the dataset back to the data source, wouldn't i have to modify my updateSQL statement to just UPDATE LoginTable ? unless i place this inside the for loop to update each time a row value is changed? also, why is a question mark placeholder necessary in the statement? i've read the msdn for the .parameter stuff but am still blur...why do i still have to specify them if the data adapter reflected the exact actual database structure from MainDB.mdb into the dataset?
  13. i see, thanx a lot oman!
  14. oh, u mean when the tables are automatically created, they are assigned with default names like table1 or table2, not the original table name as in the real database? adapter.Fill(ds, "LoginTable") when i use this command to fill a dataset, the second argument here has to be a data table object...wat do i write in here when i am filling from an existing data source and have no data table ob ject created?
  15. If i fill a data set with data from an existing data source through a data adapter, with a table from a databsae, the table will be automatically created in the data set rite? so do i still need to declare a data table instance to represent this table from my database?
  16. ok, er.......i'll post the whole body of code as below : conStr = "Provider=Microsoft.JET.OLEDB.4.0;data source=MainDB.mdb" conn = New OleDbConnection(conStr) sqlStr = "SELECT * FROM LoginTable" cmSQL = New OleDbCommand(sqlStr, conn) cmSQL.CommandTimeout = 30 adapter = New OleDbDataAdapter(sqlStr, conn) adapter.SelectCommand = cmSQL ds = New DataSet() adapter.Fill(ds, "LoginTable") dt = New DataTable() dt = ds.Tables(0) numrows = dt.Rows.Count Dim updateSQL As String = "UPDATE LoginTable SET Username = ? WHERE Username = ?" cmSQL.CommandText = updateSQL adapter.UpdateCommand() = New OleDbCommand(updateSQL, conn) adapter.UpdateCommand.Parameters.Add("Username", OleDbType.VarWChar) Dim workParm As OleDbParameter = adapter.UpdateCommand.Parameters.Add("Username", OleDbType.VarWChar) workParm.SourceColumn() = "Username" workParm.SourceVersion = DataRowVersion.Original For i = 0 To numrows - 1 Dim temp As String = dt.Rows(i).Item("Username") dr = ds.Tables("LoginTable").Rows(i) dr("Username") = UCase(temp) adapter.Update(ds) Next sorry that i misplaced some lines of code the last time, i modified a few lines... ok, actually wat i want to do is to loop through records in a table, and change the username value to upper case, no matter wat, just to read in the value and to reassign the username field with an upper case version of the former...that's all i'm actually confused about the purpose of parameters, i tried to follow the msdn article, that's y i added it there, but to be honest, i do not know why i need it... i don't know why i need to put (?) placeholders in my updateSQL statement cmSQL.CommandText = updateSQL 'cmSQL is your selection string above, right? 'Since in the next line you declare your 'update command string using the updateSQL string I don't 'see the value in reassigning this value. adapter.UpdateCommand() = New OleDbCommand(updateSQL, conn) so u mean i can remove the cmSQL.commadntext = updateSQL line? wat should i do here? overall, i get errors, even an error related to being una ble to find table mapping or datatable ("Table"), i dunno why this error is coming up,m maybe it is due to errors in earlier sections of my code here, wat do u think (this is all that's in the code)?
  17. I have used this code. I keep getting an error at the line where i invoke the data adapter fill method for the second time, they state that i have not specified a parameter. But i see no difference between the 1st and 2nd time i invoke the fill method. Can anybody help me see wat's wrong? conStr = "Provider=Microsoft.JET.OLEDB.4.0;data source=MainDB.mdb" conn = New OleDbConnection(conStr) sqlStr = "SELECT * FROM LoginTable" cmSQL = New OleDbCommand(sqlStr, conn) cmSQL.CommandTimeout = 30 adapter = New OleDbDataAdapter(sqlStr, conn) adapter.SelectCommand = cmSQL ds = New DataSet() adapter.Fill(ds, "LoginTable") dt = New DataTable() dt = ds.Tables(0) numrows = dt.Rows.Count Dim temp As String = dt.Rows(i).Item("Username") Dim updateSQL As String = "UPDATE LoginTable SET Username = ? WHERE Username = ?" cmSQL.CommandText = updateSQL adapter.UpdateCommand() = New OleDbCommand(updateSQL, conn) adapter.UpdateCommand.Parameters.Add("Username", OleDbType.VarWChar) Dim workParm As OleDbParameter = adapter.UpdateCommand.Parameters.Add("Username", OleDbType.VarWChar) workParm.SourceColumn() = "Username" workParm.SourceVersion = DataRowVersion.Original adapter.Fill(ds, "LoginTable") oh yah, if i wanna post vb code in here, wat tags do i need to insert? so that nex time i can use it...
  18. hm......given the situation, the onli way out seems to be to create 2 separate connections so that i can use both the data reader and update the datrabase at the same time without conflicts of the using the same connection item...is there a way i could still use the same connection item?
  19. i would like to apologise if the file is too big...
  20. wat i mainly want to do is to loop thru records in a table and then to update each record in the table to UPPER case no matter wat even if it is alreayd in upper case... but since i'm using the data reader to loop thru, when i want to update, i get an error msg coz the data reader is already using the connection item... i have read ur short tutorial above...i dojn't really get it... could u help me out? probably just directly give me an idea on wat code or algorithm i should employ, i think i'll learn about the database concepts later, as i find it too confusing, don't really understand... windowsapplication1.zip
  21. i have read ur article, but i still do not know how to apply it into my situation as i'm not sure if i've explained to u my situation clearly enough, i think i'll attach my project here, maybe you could better help me if u could see my error, thanx...
  22. i see, okok, give3 me some time to digest this first, thanx a lot for the tremendous effort to help me...
  23. oh, but wat i want to achieve is not to display the data, just to read the data without having to display it, and then merely modify the value of each field of each record in the database, that's all actually...but my problem was that the reader was taking up the connection item, therefore i could not execute another sql statement becoz of htis...so as u said, if the data reader is read only, then i'll have to use somnething else right? er........wat else can i use without having to display the data?
  24. why i'm resorting to a for loop is becoz this while loop with the read function won't work (reader is declared as a oledbdatareader) if i exectue the "cmSQL.executenonquery" within this loop, i can't do this becoz they say that the connection (variable conn) is used by the reader (oledbreader), therefore i cannot use this while loop. I mainly wanna use this reader loop to read the value, and modify the value in the db within this loop. Is this confdusing? =Any ideas? 'Do While reader.Read() 'Dim temp As String = reader.GetString(0) 'sqlStr = "UPDATE LoginTable SET Username ='" & UCase(temp) & "' WHERE Username='temp'" 'cmSQL = New OleDbCommand(sqlStr, conn) 'cmSQL.ExecuteNonQuery() 'adapter = New OleDbDataAdapter() 'adapter.UpdateCommand = New OleDbCommand(sqlStr, conn) MsgBox(reader.GetString(0) & " " & reader.GetString(1), MsgBoxStyle.Information, "Test") 'Loop
  25. yeah, i have read some tutorials, i know the basics of how to create one...don't really know wat it is for... and sorry, i really don't know the differences between dataset and datareader. i know how to declare a dataset, but there are so many properties i dunno how to make use of... my sql knowledge is alright, i have done many SQL statements, so i feel i can always handle that one... thanx for helping me out here...
×
×
  • Create New...