|
I mean changing DataSource Property on Run Time
jooooo
|
|
|
|
|
This is probably the long way around but you can load a column style before you name the data source. I cannot see why you are losing the data but this will over-write anything else. See code below I copied direct from one of my old projects- where workTable is the table in my dataSet and I just iterate through the workTable column names to add then to the datagrid
Private Sub LoadCvCalcTableFormat()
' Create a new DataGridTableStyle and set MappingName.
Dim tableFormat As DataGridTableStyle = New DataGridTableStyle
tableFormat.ColumnHeadersVisible = True
tableFormat.PreferredColumnWidth = 75
tableFormat.PreferredRowHeight = 30
tableFormat.RowHeadersVisible = True
tableFormat.MappingName = workTable.TableName
' Iterate through table columns and format each one.
Dim i As Integer
For i = 1 To workTable.Columns.Count - 1
Dim colStyle1 As DataGridColumnStyle = New DataGridTextBoxColumn
colStyle1.Alignment = HorizontalAlignment.Center
colStyle1.Width = 75
colStyle1.HeaderText = workTable.Columns(i).ColumnName
colStyle1.MappingName = workTable.Columns(i).ColumnName
tableFormat.GridColumnStyles.Add(colStyle1)
Next
' Add the grid style to the GridStylesCollection.
DataGrid1.TableStyles.Add(tableFormat)
End Sub
|
|
|
|
|
So sorry my friend and thanks for your reply
I didn't link the site from large period
The code above is worked with DataGrid , but i Use DataGridView
and I want any page that give full demonstration of DataGridView
jooooo
|
|
|
|
|
Is there any one know how to implement agraph in VB.NET???
PLZ i need it as soon as possible...
|
|
|
|
|
maisa.sh wrote: Is there any one know how to implement agraph in VB.NET???
Yes.
But it depends on how you want to use the graph. However, all solutions eventually come down to drawing on some kind of surface and for that you will need to learn about the Brush , Pen and Graphics classes (see MSDN)
|
|
|
|
|
i wrote a querry sentence but there is a problem:
Syntax error (missing operator) in query expression 'like '%ç%''.
the sentence is :Dim querry As New OleDbCommand("select * from vtab where " & deger & " like '%" & Me.TextBox1.Text & "%'", baglanti)
|
|
|
|
|
nbulut wrote: OleDbCommand("select * from vtab where " & deger & " like '%" & Me.TextBox1.Text & "%'", baglanti)
Don't inject values in to a SQL statement. Use parameterised queries. Also, sanitise your input. You are injecting the value of the text box directly into the SQL. This blasts a huge security hole right through your application.
Read this article[^] and it will help you solve your current problem and plug the security holes in your code at the same time. Two for the price of one!
|
|
|
|
|
not sql the database is access is the article helpful for access
|
|
|
|
|
nbulut wrote: not sql the database is access is the article helpful for access
Do you mean you are not using "SQL Server". "SQL" is the language used to communicate with relational databases, which they all pretty much understand.
From the first paragraph of the article: "Although the technologies used here are SQL Server 2000 and the .NET Framework, the general ideas presented apply to any modern data driven application framework, which makes attacks potentially possible on any type of application that depends on that framework."
So, yes, it is still relevant to Access even although the examples may need to be tweaked slightly.
The main difference is that parameters in access are denoted by ? placeholders, rather than the specifically named parameters in SQL Server. This means that you must add the parameters to your query in the order in which the query encounters the ? placeholder.
|
|
|
|
|
can u give me an example
i am a beginner of progamming and my english is normal so i dont know what to do
i want to have the words which the user types in text box when u type the programme shows all the words in a list box which starts with a
oh i am sorry about asking too many simple questions
|
|
|
|
|
I'm typing this directly so there may be some minor errors:
Dim someValue As String;
someValue = "%" & theTextBox.Text & "%"
myCommand.CommandText = "SELECT * FROM MyTable WHERE someColumn LIKE ?"
myCommand.Parameters.Add("?", someValue)
You may also wish to validate that the information the user has put in the text box is no longer than the length of the column, or check for any other conditions that make the value invalid before sending it to the database.
|
|
|
|
|
Hi ,
i am using the following code where "_sessionCalibrationSessionMasterDTO" and "_calibrationSessionMasterDTO" are of same kind of objects having different properties.
/*
Dim _calibrationSessionMasterDTOs As IList(Of CalibrationSessionMasterDTO) = New List(Of CalibrationSessionMasterDTO)
Dim _calibrationSessionMasterDTO As CalibrationSessionMasterDTO = DTOFactory.GetNewCalibrationSessionmasterDTO()
*/
One of the property is "NoofSessions" and other one is "SessionNumber"
First of all i'm checking the following condition and based on it i'm adding the "_calibrationSessionMasterDTO" into a list of same kind of object "_calibrationSessionMasterDTOs"
For _count As Integer = 1 To _sessionCalibrationSessionMasterDTO.NoofSessions
_calibrationSessionMasterDTO.SessionNumber = _count
_calibrationSessionMasterDTOs.Add(_calibrationSessionMasterDTO)
Next
Now the main problem is that for _count = 1 its working fine (there is no previous member) but as soon as _count increases the previous member of list _calibrationSessionMasterDTOs are updating with the latest one.
I have tried to initialize the object _calibrationSessionMasterDTO every time before adding it to the list but nothing happened.
I have also tried to insert these values instead of adding but nothing happened.
For example if _count = 1 and _calibrationSessionMasterDTO.SessionNumber = 1 then this loop is working fine.
but for _count=2 and _calibrationSessionMasterDTO.SessionNumber = 2 then
the previous value of _calibrationSessionMasterDTO.SessionNumber is updated by the latest one i.e. 1 is updated by 2...
please help me if any one having any idea...
If you can reply at earliest then it wud be gr8
|
|
|
|
|
Your new creating a new _calibrationSessionMasterDTO object before you add it to the collection. You're modifying the existing one and re-adding it over and over again. Change it to:
For _count As Integer = 1 To _sessionCalibrationSessionMasterDTO.NoofSessions
Dim newobj As CalibrationSessionMasterDTO = DTOFactory.GetNewCalibrationSessionmasterDTO()
newobj.SessionNumber = _count
_calibrationSessionMasterDTOs.Add(newobj)
Next
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
jds1207 wrote: ("Provider=MySQLProv;Data Source=testship;User Id=jsimmonsassword=dway1207;")
Thanks for the username and password! (You might want to remove those from future posts.)
jds1207 wrote: Dim conn As New OleDb.OleDbCommand("", myConnString)
conn.Connection.Open()
Dim read As OleDb.OleDbDataReader = conn.ExecuteReader(CommandBehavior.CloseConnection)
You created an OleDbCommand object, but didn't give it an SQL statement to execute before you called ExecuteReader on it. The reader object won't work without it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Anyone know of a control similar to a picture box but with clipping and stretching capability? I need a quick fix.
Thanks.
B.J.
|
|
|
|
|
The PictureBox does do this, a little, but really, you need to draw your own bitmaps if you want full control, in your Paint handler.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I searched and looked around but haven't been able to find an adaquate answer and I feel stu-pid for having to ask.
I am trying to use the ntgraph control on an access form.
I have it registered and it works fine in Excel.
I cannot seem to access it properly in Access though. Whenever I reference it as follows:
with me.ntgraph0
.plotxy (1,1,1) <--- this is not an available method
end with
I apologize for the newbie question. It is a control that I can definitely use, I'm just missing something.
Thanks
|
|
|
|
|
hey guys
i have a project that uses an ms access database as a data source.
and it uses a connection string which specifies the path of the database.
now i would like to use that feature where is copies the database to the output directory
and uses the new copy as a data source (this is available as a built in option when
i create a new data source)
but i'd like to apply this feature on my current data source.
unfortunately everything i've tried causes either my data source not to work,
or renames certain things (like adds a _1 to the name and doesn't reflect on my existing queries)
or clears off all the queries on the dataset.
does anyone know of a quick and painless method ? hopefully something i overlooked?
thanks in advance
Ericos Georgiades
|
|
|
|
|
dear sir
Actually I have some problem with some TAPI function!! It is (LineGetCountry()) tapi function.
I declared LineGetCountry() function & its struct LINECOUNTRYLIST struct & LINECOUNTRYENTRY struct within a module ………….ok
The problem of mine is how to deal with LINECOUNTRYLIST & LINECOUNTRYENTRY structs within my Visual Basic code in the form to retrieve following:
A specific country code & country name.
Note: LineGetCountry() function is returning 0 so it’s successfully invoked
But *.dwCountryCode still retuning zero
I will be very graceful if you could help me by providing me with some example explain how to get country name &country telephone code, by any chance. (visual basic if possible).
thanks
|
|
|
|
|
Let's see your code for defining the structures, the declare for the function, and how your calling ListGetCountry(). The most common problem is that something was declared with the wrong data type, especially if your trying to convert old VB6 code to VB.NET.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I need a source code that view installed applications and run them.
Thanks.
|
|
|
|
|
Sorry, noone here jsut hands over source code for an entire project. If there is a specific area your having a problem with then great, we can help. But if your looking for someone to write everything for you, try RentACoder.com.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have the following code that fills a DataGrid
<small>
Dim strSQLCustomerTotals As String = "SELECT OrderID, OrderTotal, Ordered_On FROM OrderTotals WHERE CustomerID=" & intCustomerId
Dim strSQLCustomerOrders As String = "SELECT * FROM Orders WHERE CustomerID=" & intCustomerId
Dim dsCustomerTotals As New DataSet
Dim daCustomerTotals As New OleDbDataAdapter(strSQLCustomerTotals, dbConn)
Dim daCustomerOrders As New OleDbDataAdapter(strSQLCustomerOrders, dbConn)
daCustomerTotals.Fill(dsCustomerTotals, "OrderTotals")
daCustomerOrders.Fill(dsCustomerTotals, "Orders")
Dim dataRelations As New DataRelation("Orders", _
dsCustomerTotals.Tables("OrderTotals").Columns("OrderID"), _
dsCustomerTotals.Tables("Orders").Columns("OrderID"))
dsCustomerTotals.Relations.Add(dataRelations)
dgCustomerTotals.DataSource = dsCustomerTotals.Tables("OrderTotals")
</small>
The column Ordered_On in the (ms access) database is a timestamp and has the format dd/MM/yyyy HH:mm:ss.
When the DataGrid is filled it only shows dd/MM/yyyy.
How do I show the full timestamp in dd/MM/yyyy HH:mm:ss format in the DataGrid?
|
|
|
|
|
The date/time in any database doesn't have a format. It's stored as a serial number value. Only when the data is displayed in a table view in Access does it get formatted. You have to do the same thing in your code. If you've created your own columns, it's pretty easy, click[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi all,
which toll/add-in (like VBDOX or doxygen) do you use to comment your source code and generate the documentation for your VB2005 projects?
Thanks in advance,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|