Tag: vb.net

How do i assign 2 values from different tables into 1 variable name as foreign key using Entity Framework-Code First

I’m confused with the foreign key concept. I’m trying to arrange the key relationships in each database class according to the Code First concept in Entity Framework. I have 3 tables: a, b and c. Table a has aId as primary key(PK), table b has bId as PK, table c has cId as primary key. […]

Extract data from table SQL

What is the best way to achieve the scenario below; We are extracting data from ten different files from ten different customers. we extract and load data into Database. the data is of the form code and description. e.g. Code Description 1 Cigrette 2 Gift 3 Bear I want to extract only Gift items but […]

Create SQL database with specific path

I need to create SQL database with specific path. I found this code: Dim fullpath As String = TextBox4.Text & TextBox1.Text & “_data.mdf” Dim fullpath1 As String = TextBox4.Text & TextBox1.Text & “_log.ldf” Dim ExtLog As String = TextBox1.Text & “_Log” Dim ExtDat As String = TextBox1.Text & “_Data” Dim myConn As SqlConnection = New […]

How to add multiple custom codes into rdlc and call separately in expression

How to add multiple custom codes into rdlc and call separately in expression ? What happened is I have already put one set of vb.code Custom Code into my RDLC report. Now I have to use another different set of Custom Code in the same report and call each of them from expression to use […]

Iterate through a DataTable and Save Data in another Database – all dynamic

I have been tasked with making a VB app to move SQL tables from one server to another based on certain criteria. The tables are in a variety of databases and the schema could be potentially different on each table. So far I am: Creating a list of tables that meet the criteria For Each […]

Inserting multiple data tables from stored procedure into strongly typed/named dataset

I have a SQL Server stored procedure that returns several tables. I am accessing these in VB via a data adapter with table mapping in the following method: da.SelectCommand = sqlCommand da.TableMappings.Add(“Table”, “SettingsTable”) da.TableMappings.Add(“Table1”, “MainDataTable”) da.Fill(dsResult) The issue I have here is around the source table name. These automatically generate as Table, Table1, Table2 etc. […]

Bind multiple tables to a DataGridView in .net and sql server

I am working on a project to manage the inventory of a small business. I have a database with SQL server 2014 that contains several tables including: “Inventory”, “Product”, “Location”, “Department”, “Provider”. I am currently using the offline method ado.net. I can’t use LINQ 🙁 I need to select certain fields from 5 tables listed […]

Return value from stored procedure is not correct

I have this stored procedure in SQL Server 2016: SET NOCOUNT ON; SELECT * FROM MyTable; RETURN @@ROWCOUNT When I run this procedure in SSMS the return value is 43, as it should be. I have this code snippet in my application: com = New SqlCommand(“MyQuery”, conn) com.CommandType = CommandType.StoredProcedure prm = New SqlParameter With […]

How do I save date and time and then sort them from new to old in datagridview, I'm using Visual Studio 2015 and SQL server

In Visual Studio I have: ‘Label15.Text = DateTime.Now.ToString(“dd/M/yyyy(dddd) hh:mm:ss:tt”) Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Label15.Text = DateTime.Now.ToString(“dd/M/yyyy(dddd) hh:mm:ss:tt”) Label16.Text = DateTime.Now.ToString(” hh:mm:ss tt “) End Sub In sql server currently I’m using a nvarchar data type, what data type should I use? what im trying to do is make a […]

Using combo-box as filter to show chart by time in vb.net using sql

I am trying to show total sales charts by (Day,week, month, year) using items in combo box as filter querying from sql in vb.net. Please help. My codes are below, which throws the error saying ‘cannot find table 0’. cboxGroupBy.Items.Insert(0, “Day”) cboxGroupBy.Items.Insert(1, “Week”) cboxGroupBy.Items.Insert(2, “Month”) cboxGroupBy.Items.Insert(3, “Year”) SQL.ExecQuery(“SELECT Date = DATEPART(‘” + Me.cboxGroupBy.Text + “‘, […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.