Create New Account
help
1 Next = = = = > tmpds(Index) = dbManager.ExecuteDataSet(cmd) tmpds.Tables(0).Rows(Index) = dbManager.ExecuteDataSet(cmd) Error 1 Property 'Item' is 'ReadOnly'. C: \ SourceControl_mcupryk \ InHouseDev \ APPS \ MKT0003 - CustomerList \ src \ CustomerList \ App_Code \ BOL localhost / CustomerList / I just want to add a row each time the loop is executed. DataTable myTable = tmpds.Tables[0]; DataRow row = myTable.NewRow(); row.ItemArray = [your object array] / / or: row[ColumName] = value; myTable.Rows.Add(row); Error 1 Value of type 'System.Data.DataSet' cannot be converted to '1-dimensional array of Function GetBusinessCalendarPeriod( ByVal dbName As String , ByVal DatePeriod As String , ByVal txtMaxPeriod As String ) As DataTable Dim retVal As New DataTable( "BusinessCalendars" ) Dim DtPeriod As String = DatePeriod Dim MaxPeriod As Integer
display the imported data in the datagrid SqlDataAdapter da = new SqlDataAdapter ( "select * from Table1" , SqlConstr); DataTable dt = new DataTable (); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); } hi, use this Example code: Imports System Data Source = Servername;Initial Catalog = mydb;Integrated Security = True" ) Dim sel As String = "SELECT * FROM myTable" da = New SqlDataAdapter(sel, conn) cb = New SqlCommandBuilder(da) da.MissingSchemaAction = MissingSchemaAction.AddWithKey da.Fill(ds2, "myTable" ) Me .DataGridView1.DataSource = ds2 Me .DataGridView1.DataMember = "myTable" End Sub Private Sub Button3_Click( ByVal sender As System. Object , ByVal e As System.EventArgs Handles Button3.Click For Each dr As DataRow In ds1.Tables(0).Rows Dim expression As String expression = "myId = " + CType (dr.Item(0), Integer ).ToString Dim drs() As DataRow = ds2.Tables(0). Select (expression) If (drs.Length = 1) Then For i As Integer = 1 Columns.Count - 1 drs(0).Item(i) = dr.Item(i) Next Else Dim drnew As DataRow = ds2.Tables(0).NewRow For i As Integer = 0 To ds2.Tables(0).Columns.Count
MyCommand As SqlDataAdapter MyCommand = new SqlDataAdapter("exec s_get_table1", MyConnection) DS1 = new DataSet() MyCommand.Fill(DS1, "MyTable") MyCommand = new SqlDataAdapter("exec s_get_table2", MyConnection) DS2 = new DataSet() MyCommand.Fill(DS2, "MyTable") 'Now this code works because the table name for both datasets are the same. 'Also the data type and column name for schema of two tables are not the same? In this example we saw that the table structure of both tables (table1 and table2) are the same. If the datatype of the is obvious that the merge will not take place. Even the compiler will give an error, such as: <target> .destination and <source> .destination have conflicting properties: DataType property mismatch. [C#] private void DemonstrateMergeTable(){ / / Create a DataSet with one table, two columns, and ten rows. DataSet ds = new DataSet( "myDataSet DataTable t = new DataTable( "Items" ); / / Add table to the DataSet ds.Tables.Add(t); / / Add columns DataColumn c1 = new
value. means automatically swap value to the blank column. because of this it gives below error. Bulk load data conversion error (truncation) for row 5, column 33 (PAGE_COUNT). let me know. plz solve this asap Regards CSVTest FROM 'c: \ csvtest.txt' WITH ( FIELDTERMINATOR = ', ' , ROWTERMINATOR = ' \ n' ) GO - -Check the content of the table. SELECT * FROM CSVTest GO also see more issue related to bulk insert form csv file http: / / www.eggheadcafe.com / community / aspnet / 14 / 82644 / importing-csv-file-into-sql-server-using-vb-net.aspx If the column in your destination table allows null, you should see the NULL gets inserted. HI using ( SqlConnection cn = new SqlConnection Having said that, you can always use OpenRowSet to import data from Excel to a table in SQL Server. Like: INSERT INTO dbo.dummyTable SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4 do your connection stuff here: while (!Sr.EndOfStream) { s = Sr.ReadLine(); cmd.CommandText = "INSERT INTO MyTable Field1, Field2, Field3 VALUES(" + s.Split( ', ' )[1] + ", " + s.Split( ', ' )[2] + ", " + s.Split( ', ' )[3] + ")" ; cmd.ExecuteNonQuery
how to import the file through vb.net code? Imports System.Data Imports System.Data.SqlClient Imports System.Data.OracleClient Imports System Imports DataSet Dim ErrExc As New ErrorHandler Dim ds1, ds4 As New DataSet Dim objDatatable As DataTable Dim exe As System.Data.OleDb.OleDbCommand Dim dr As DataRow Dim oracleBulkCopy As String Dim strNewPath As String Dim sFileDir As String Dim query As ds = New DataSet() da.Fill(ds) Dim ds1 As New DataSet() Dim dt As New DataTable("badge") Dim cl1 As New DataColumn("PlazaNo") cl1.DataType = GetType(String) Dim cl2 As New Of String) For i = 0 To ds.Tables(0).Rows.Count - 2 Dim badge As DataTable = New DataTable badge.Columns.Add("PlazaNo") badge.Columns.Add("BadgeNo") badge.Columns.Add("GroupLevel") badge.Columns.Add Tables(0).Rows(i)("HQBD_PASSWORD") strMFGNo = ds.Tables(0).Rows(i)("HQBD_MFGNO") Dim objDatarow As DataRow = badge.NewRow() objDatarow("PlazaNo") = strplazano objDatarow("BadgeNo") = strbadgeno objDatarow("GroupLevel") = strgrouplevel objDatarow("BadgeName") = strbadgename objDatarow