Click here to Skip to main content
15,499,573 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am new in React Native and my database is connected with Microsoft SQL. Now I want to bind data from Microsoft SQL Server to FlatList in React Native. Here is my code. Please help.

What I have tried:

import { StyleSheet, Text, View } from "react-native";
import React from "react";
import MSSQL from "react-native-mssql";

const config = {
  server: "******", //ip address of the mssql database
  username: "***", //username to login to the database
  password: "*******", //password to login to the database
  database: "******", //the name of the database to connect to
  port: 16000, //OPTIONAL, port of the database on the server
  timeout: 5, //OPTIONAL, login timeout for the server

const DataFunction = async () => {
  const connected = await MSSQL.connect(config);
  const query = "SELECT class FROM cls_sec";
  const result = await MSSQL.executeQuery(query);
  const closed = await MSSQL.close();
Updated 4-Mar-22 7:10am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900