|
Dim ds As DataSet = New DataSet
ds.ReadXml("FileName Here")
Dim btn As New DataGridViewButtonColumn
btn.Text = "Add New"
DataGridView1.column.add(btn)
BEST LUCK
|
|
|
|
|
dear sir This is my code.I can add the check box by using this code Now i need the Command button.Your code doesnot work.Please hope for kind coperation.
'btn1_click()
'Dim filePath As String
'filePath = "D:\authors.xml"
'dsAuthors.ReadXml(filePath)
'With dg
' .DataSource = dsAuthors
' .DataMember = "Authors"
' .CaptionText = .DataMember
' Dim dtcCheck As New DataColumn("New Column")
' dtcCheck.DataType = System.Type.GetType("System.Boolean")
' dtcCheck.DefaultValue = False
' dsAuthors.Tables(0).Columns.Add(dtcCheck)
'End With
end sub
|
|
|
|
|
I ran the code below that adds a column to an SQL table.
I refreshed Data Sources, but, the new column does not appear.
I refreshed Server Explorer and the new column does not appear.
I tried running the code again and I got:
"Column names in each table must be unique. Column name 'CaseNbr' in table 'Patient' is specified more than once."
so the column did actually get added, but, I can't see it.
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sqlConnection As New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Patient.mdf;Integrated Security=True;User Instance=True")
Dim str As String = "ALTER TABLE Patient ADD CaseNbr Varchar(50)"
Dim command As New System.Data.SqlClient.SqlCommand(str, sqlConnection)
sqlConnection.Open()
command.ExecuteNonQuery()
sqlConnection.Close()
Close()
End Sub
End Class
|
|
|
|
|
I Think Ur Code is Correct if u have any confusion then please review this Code thanks
Dim cn As New SqlClient.SqlConnection
cn.ConnectionString = "Data Source=ssi-SIQBAL;Initial Catalog=Dummy;integrated Security=SSPI"
cn.Open()
Dim cmd As New SqlClient.SqlCommand
Dim str As String
str = "ALTER TABLE TBL1 ADD HOME varchar(500)"
cmd.Connection = cn
cmd.CommandText = str
cmd.ExecuteNonQuery()
|
|
|
|
|
Is the MDF file listed in your project in Solution Explorer? The problem usually occurs because the .NDF file is being copied to your Release or Debug folders along with your app's .EXE. The Server Explorer is looking at one version of the database (in your project folder) and your code is looking at the other copy of your database in the bin\Release or bin\Debug folder.
Wanna see? Just open your project folder and search all the subfolders for any files with the extension MDF.
|
|
|
|
|
That was the problem.
Another question:
Why is it that in some projects, the .mdf file is in bin\Release
and in other projects, the .mdf file is in the bin\Debug folder?
|
|
|
|
|
It'll be in either depending on which build configuration you use when you hit, well, Build.
|
|
|
|
|
OK, I deleted the Patient.mdf in Server Explorer.
Then I opened a New Connection and browsed to the .mdf file under the output directory (\bin\debug).
Now I can see the new column in Server Explorer.
But, how do I get it to appear in Data Sources of Solution Explorer?
|
|
|
|
|
You don't want to do that. You just have to understand that the Server Explorer will look at the copy of the database in the Project folder and your running code will look at the copy in the bin\ folders.
Why? Because when you build the project, by default, the database in the project folder will be copied to the bin\ folders every time you build the project. This will overwrite the bin\ folder copy, and any changes your code makes to it.
If this is a permanent change you want to make to the project folder copy, either use the SQL Server Management Studio to make the change, or the Server Explorer, or make the change with your code, then copy the bin\folder version up to the project folder.
|
|
|
|
|
Hi everybody
I need help in resolving an issue, as below.
After installing Visual Studio 2005, with SQL Server Express, on my PC; when I try to add a new connection it reports the following error:
"An error has occurred while establishing a connection to the server. When connecting to the SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (Provider: Named Pipe Provider, error: 40 - could not open a connection to SQL Server)"
I am using the following parameters:
Data Source: Microsoft SQL Server (SqlClient)
Server name: Desktop ( this is the name of my PC)
Attach a database file: test.mdf (it is just for an example)
I have un-installed and re-installed the application twice but the problem persists.
I would appreciate any help.
Regards,
|
|
|
|
|
The Data Source should be .\SQLEXPRESS . The server name doesn't need to be filled in at all. And the Attach a database file should list the FULLY qualified path to the MDF file, not just the filename.
|
|
|
|
|
Thanks for the response.
The problem is that the drop-down list in the "Add Connection" dialogbox does not have the SQLEXPRESS Server name. Secondly, I select the attached database file by browse button and so it should not be a problem.
However, the installation of the SQL Server did not offer me to provide or suggest the Server name.
A more deep-down suggestion will be highly appreciated.
|
|
|
|
|
Click the Advanced button in that dialog. Then it's just a matter of filling in the blanks.
|
|
|
|
|
|
does S has any meaning while writing OOPS
object oriented programming S???
Develop2Program & Program2Develop
|
|
|
|
|
Navneet Hegde wrote: does S has any meaning while writing OOPS
Writing "OOPS" is a mistake in the first place. The term is Object-oriented programming[^], OOP.
There is no plural form "OOPs" of OOP. It would be like saying "gardenings" or "tv watchings".
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: It would be like saying "gardenings" or "tv watchings".
Borat would say it like that...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You just asked this question and it was already answered.
__________________
Bob is my homeboy.
|
|
|
|
|
how can i draw multiple image into the same picturebox using BitBlt function?
|
|
|
|
|
You can't, you'd have to build a composite image of those bitmaps. The picture box is just for people who want to put up a single image, it's assumed if you want to do more, you will draw it yourself.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am just a bit too lazy to spend a few hours finding it,if someone knows the location of the key i mentioned ,plz tell where it is.
|
|
|
|
|
Vivek Narayanan wrote: ,plz tell where it is.
Nope. Why? This is why...
Vivek Narayanan wrote: I am just a bit too lazy to spend a few hours finding it
|
|
|
|
|
HEY!,Not Fair,anyone else?
|
|
|
|
|
Whats not fair is saying "I'm too lazy to do it myself", then expecting someone to do it for you. Do your own damn work!
|
|
|
|
|
Hi all,
I got syntax error when I update the database, and I don't know what I;m did wrong. Can some of you give me some hints
I have a database table, with the field "First Name","Last Name" ,
"Phone","Age" and "Status"
I don't know is the problem due to the tag "First Name" with the space character?
the following is my code for create OleDbDataAdapter:
<br />
Dim adapter As OleDbDataAdapter = New OleDbDataAdapter(selectCommand, connection)<br />
<br />
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey<br />
<br />
adapter.InsertCommand = New OleDbCommand( _<br />
"INSERT INTO wpGuest (First Name, Last Name, Phone, Age, Status) " & _<br />
"VALUES (?, ?, ?, ?, ?)", connection)<br />
<br />
<br />
adapter.UpdateCommand = New OleDbCommand( _<br />
"UPDATE wpGuest SET First Name = ?, Last Name = ? , Phone = ? , Age = ? , Status = ? " & _<br />
"WHERE First Name = ?", connection)<br />
<br />
<br />
adapter.DeleteCommand = New OleDbCommand("DELETE FROM wpGuest WHERE First Name = ?", connection)<br />
<br />
<br />
' Create the parameters.<br />
adapter.InsertCommand.Parameters.Add( _<br />
"@First Name", OleDbType.Char, 50, "First Name")<br />
adapter.InsertCommand.Parameters.Add( _<br />
"@Last Name", OleDbType.Char, 50, "Last Name")<br />
adapter.InsertCommand.Parameters.Add( _<br />
"@Phone", OleDbType.Char, 50, "Phone")<br />
adapter.InsertCommand.Parameters.Add( _<br />
"@Age", OleDbType.Char, 50, "Age")<br />
adapter.InsertCommand.Parameters.Add( _<br />
"@Status", OleDbType.Char, 50, "Status")<br />
<br />
<br />
<br />
adapter.UpdateCommand.Parameters.Add( _<br />
"@First Name", OleDbType.Char, 50, "First Name").Value = "c"<br />
adapter.UpdateCommand.Parameters.Add( _<br />
"@Last Name", OleDbType.Char, 50, "Last Name").Value = "c"<br />
adapter.UpdateCommand.Parameters.Add( _<br />
"@Phone", OleDbType.Char, 50, "Phone").Value = "c"<br />
adapter.UpdateCommand.Parameters.Add( _<br />
"@Age", OleDbType.Char, 50, "Age").Value = "c"<br />
adapter.UpdateCommand.Parameters.Add( _<br />
"@Status", OleDbType.Char, 50, "Status").Value = "c"<br />
adapter.UpdateCommand.Parameters.Add( _<br />
"@First Name", OleDbType.Char, 50, "First Name").SourceVersion = _<br />
DataRowVersion.Original<br />
<br />
<br />
adapter.DeleteCommand.Parameters.Add( _<br />
"@First Name", OleDbType.Char, 50, "First Name").SourceVersion = _<br />
DataRowVersion.Original<br />
<br />
|
|
|
|
|